恢复异常处理程序:
<?php
// 两个用户定义的异常处理函数
function myException1($exception) {
echo "[" . __FUNCTION__ . "]" . $exception->getMessage();
}
function myException2($exception) {
echo "[" . __FUNCTION__ . "]" . $exception->getMessage();
}
set_exception_handler("myException1");
set_exception_handler("myException2");
restore_exception_handler();
// 抛出异常
throw new Exception("This triggers the first exception handler...");
?>
以上代码的输出类似这样:
[myException1] This triggers the first exception handler...
restore_exception_handler() 函数恢复之前的异常处理程序。
在使用 set_exception_handler() 改变异常处理函数之后,此函数可以用于还原之前的异常处理程序。
restore_exception_handler();
返回值: | 始终返回 TRUE。 |
---|---|
PHP 版本: | 5.0+ |
©2020 IT自习室京ICP备20010815号