首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

restore_exception_handler

(PHP 5, PHP 7)

restore_exception_handler - 恢复先前定义的异常处理函数

描述

代码语言:javascript
复制
bool restore_exception_handler ( void )

在使用set_exception_handler()更改异常处理函数之后使用,以恢复到之前的异常处理程序(可能是内置函数或用户定义的函数)。

返回值

这个函数总是返回TRUE

例子

示例#1 restore_exception_handler()示例

代码语言:javascript
复制
<?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...');
?>

上面的例子将输出:

代码语言:javascript
复制
[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 →

扫码关注腾讯云开发者

领取腾讯云代金券

http://www.vxiaotou.com