PHP restore_exception_handler() 函数

PHP Error 和 Logging 函数


Example

恢复异常处理程序:

<?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+

PHP Error 和 Logging 函数

本教程仅供参考学习,如用于商业带来的问题,本站概不负责。
关注公众号
关注公众号

©2020 IT自习室京ICP备20010815号