Created
September 6, 2011 15:38
-
-
Save mtabini/1197888 to your computer and use it in GitHub Desktop.
Catching PHP Warnings
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
error_reporting(E_ALL | E_STRICT); | |
function myHandler($errno, $errstr) { | |
throw new Exception($errstr, $errno); | |
} | |
set_error_handler('myHandler', E_ALL | E_STRICT); | |
try { | |
$result = file_get_contents('http://phparch.com/i_dont_exist'); | |
} catch (Exception $e) { | |
// File not found or other error. | |
var_dump($e); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment