restore_exception_handler
(PHP 5, PHP 7)
restore_exception_handler - 恢复先前定义的异常处理函数
描述
bool restore_exception_handler ( void )
在使用set_exception_handler()更改异常处理函数之后使用,以恢复到之前的异常处理程序(可能是内置函数或用户定义的函数)。
返回值
这个函数总是返回TRUE
。
例子
示例#1 restore_exception_handler()示例
<?php
????function?exception_handler_1(Exception?$e)
????{
????????echo?'['?.?__FUNCTION__?.?']?'?.?$e->getMessage();
????}
????function?exception_handler_2(Exception?$e)
????{
????????echo?'['?.?__FUNCTION__?.?']?'?.?$e->getMessage();
????}
????set_exception_handler('exception_handler_1');
????set_exception_handler('exception_handler_2');
????restore_exception_handler();
????throw?new?Exception('This?triggers?the?first?exception?handler...');
?>
上面的例子将输出:
[exception_handler_1] This triggers the first exception handler...
- set_exception_handler() - 设置用户定义的异常处理函数
- set_error_handler() - 设置用户定义的错误处理函数
- restore_error_handler() - 恢复以前的错误处理函数
- error_reporting() - 设置报告哪些 PHP 错误
← restore_error_handler
set_error_handler →
本文档系腾讯云开发者社区成员共同维护,如有问题请联系 cloudcommunity@tencent.com