PHP restore_error_handler() 函数
PHP restore_error_handler() 函数恢复之前的错误处理程序
该函数用于在通过 set_error_handler() 函数改变后恢复之前的错误处理程序
函数原型
restore_error_handler()
返回值
总是返回 TRUE
注意
之前的错误处理程序可能是在内建的错误处理程序或用户自定义函数中构建的
范例
<?php //custom error handler function function customError($errno, $errstr, $errfile, $errline) { echo "<b>Custom error:</b> [$errno] $errstr<br />"; echo " Error on line $errline in $errfile<br />"; } //set user-defined error handler set_error_handler("customError"); $test=2; //trigger error if ($test>1) { trigger_error("A custom error has been triggered"); } //restore built-in error handler restore_error_handler(); //trigger error again if ($test>1) { trigger_error("A custom error has been triggered"); }
运行以上 PHP 范例,输出结果如下
Custom error: [1024] A custom error has been triggeredError on line 14 in C:\webfolder\test.php Notice: A custom error has been triggered in C:\webfolder\test.php on line 21