restore_error_handler
Restores the previous error handler function
&reftitle.description;
boolrestore_error_handler
Used after changing the error handler function using
set_error_handler, to revert to the previous error
handler (which could be the built-in or a user defined function). This
function always returns &true;.
See also error_reporting,
set_error_handler,
restore_exception_handler,
trigger_error.
The example below shows the handling of internal exceptions by
triggering errors and handling them with a user defined function. It then
restores the original PHP error handling:
Error handling with set_error_handler,
trigger_error and
restore_error_handler
My FATAL [$errno] $errstr
\n";
echo " Fatal error in line $errline of file $errfile";
echo ", PHP " . PHP_VERSION . " (" . PHP_OS . ")
\n";
echo "Aborting...
\n";
exit(1);
break;
case E_USER_WARNING:
echo "My ERROR [$errno] $errstr
\n";
break;
case E_USER_NOTICE:
echo "My WARNING [$errno] $errstr
\n";
break;
default:
echo "My unkown error type: [$errno] $errstr
\n";
break;
}
}
set_error_handler("myErrorHandler");
trigger_error('Test error', E_USER_WARNING);
restore_error_handler(); // Will restore standard PHP handler
trigger_error('Test error', E_USER_WARNING);
?>
]]>
&example.outputs.similar;