Skip to content

Instantly share code, notes, and snippets.

@mtabini
Created September 6, 2011 15:38
Show Gist options
  • Save mtabini/1197888 to your computer and use it in GitHub Desktop.
Save mtabini/1197888 to your computer and use it in GitHub Desktop.
Catching PHP Warnings
<?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