function fatal_error_handler() {
if ($error = error_get_last()) {
switch ($error['type']) {
case E_ERROR:
$code = 'FATAL ERROR';
break;
case E_CORE_ERROR:
$code = 'CORE ERROR';
break;
case E_CORE_WARNING:
$code = 'CORE WARNING';
break;
default:
$code = 'UNKNOWN FATAL ERROR';
}
echo 'An error occurred (Test 1): ' . $code . '<br />';
}
echo 'An error occurred (Test 2): ' . $code . '<br />';
}
register_shutdown_function('fatal_error_handler');
I'm currently writing a fatal error handler using the register_shutdown_function. Just wondering, is the register_shutdown_function supposed to run/execute automatically? I've been testing just this block of code above. I've deliberately put in the second echo statement to see if it does run automatically and it does in fact print out the second echo statement (The first echo statement is not printed since there are no fatal errors in place).