restore_exception_handler()

恢复之前通过 set_exception_handler() 函数设置的异常处理函数

首字母:R

函数名:restore_exception_handler()

适用版本:PHP 5 >= 5.1.0, PHP 7

函数描述:restore_exception_handler() 函数用于恢复之前通过 set_exception_handler() 函数设置的异常处理函数。

语法:bool restore_exception_handler ( void )

参数:无

返回值:如果成功恢复异常处理程序,则返回 true,否则返回 false。

示例:

getMessage();
}
// 设置自定义异常处理函数
set_exception_handler("customExceptionHandler");
// 抛出一个异常
throw new Exception("这是一个测试异常");
// 恢复默认的异常处理函数
restore_exception_handler();
// 再次抛出一个异常,这次会使用默认的异常处理函数
throw new Exception("这是另一个测试异常");
?>

上述示例中,我们首先定义了一个自定义的异常处理函数 customExceptionHandler(),然后通过 set_exception_handler() 函数将其设置为当前的异常处理函数。接着,我们抛出一个测试异常,这时会调用自定义的异常处理函数进行处理。最后,我们使用 restore_exception_handler() 函数恢复默认的异常处理函数,然后再次抛出一个异常,这时会使用默认的异常处理函数进行处理。

同首字母函数