Skip to content

Instantly share code, notes, and snippets.

@juji
Last active August 29, 2015 14:02
Show Gist options
  • Save juji/d3f863d999ae05ffd0c6 to your computer and use it in GitHub Desktop.
Save juji/d3f863d999ae05ffd0c6 to your computer and use it in GitHub Desktop.
PHP - error reporting control
error_reporting(E_ALL | E_STRICT);
// handle all error
ob_start(function($out){
$e = error_get_last();
if(!empty($e)) {
return $e['message'] . ' ( ' . $e['file'] . ' [' . $e['line'] . '] )';
}
return $out;
});
//handle user error
set_error_handler(function($no,$str,$file,$line){
print $str . '( '.$file.' ['.$line.'] )';
});
//exception
try{
}catch(Exception $e){
print $e->getMessage() . ' -> ' . $e->getFile() . '( '.$e->getLine().' )';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment