- var_dump: documentation ( source)
- error_get_last: documentation ( source)
- error_clear_last: documentation ( source)
- error_reporting: documentation ( source)
- htmlspecialchars: documentation ( source)
- set_error_handler: documentation ( source)
<?php
$old_error = error_reporting();
$new_old_error = null;
$bool = false;
$string = '';
$get_last = array();
// error handler function
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
global $new_old_error, $bool, $string, $get_last;
$new_old_error = error_reporting();
if (!($new_old_error & $errno)) {
// This error code is not included in error_reporting, so let it fall
// through to the standard PHP error handler
$get_last[] = error_get_last();
error_clear_last();
} else {
// $errstr may need to be escaped:
$errstr = htmlspecialchars($errstr);
switch ($errno) {
case E_USER_ERROR:
$string = $string . "<b>My ERROR</b> [$errno] $errstr<br />\n";
$string = $string . " Fatal error on line $errline in file $errfile";
$string = $string . ", PHP " . PHP_VERSION . " (" . PHP_OS . ")<br />\n";
$string = $string . "Aborting...<br />\n";
exit(1);
case E_USER_WARNING:
$string = $string . "<b>My WARNING</b> [$errno] $errstr<br />\n";
break;
case E_USER_NOTICE:
$string = $string . "<b>My NOTICE</b> [$errno] $errstr<br />\n";
break;
default:
$string = $string . "Unknown error type: [$errno] $errstr<br />\n";
break;
}
/* Don't execute PHP internal error handler */
$bool = true;
}
return $bool;
}
$old_error_handler = set_error_handler("myErrorHandler");
@$arr['is'];
var_dump($string, $get_last);