The restore_exception_handler() function restores the previous exception handler. It is used after changing the exception handler function using set_exception_handler(), to revert to the previous exception handler (which could be the built-in or a user defined function).
Syntax
restore_exception_handler()
Parameters
- NA
Return
The restore_exception_handler() function always return TRUE.
Example
The following is an example −
<?php
function customException1($exception) {
echo "[" . __FUNCTION__ . "]" . $exception->getMessage();
}
function customException2($exception) {
echo "[" . __FUNCTION__ . "]" . $exception->getMessage();
}
function customException3($exception) {
echo "[" . __FUNCTION__ . "]" . $exception->getMessage();
}
set_exception_handler("customException1");
set_exception_handler("customException2");
set_exception_handler("customException3");
restore_exception_handler();
// throwing exception
throw new Exception("Triggers the first exception handler!");
?>Output
The following is the output −
[customException1] Triggers the first exception handler!