restore_error_handler() 函数恢复之前的错误处理程序,该程序是由 set_error_handler() 函数改变的。
该函数永远返回 true。
restore_error_handler()
提示:之前的错误处理程序可能是在错误处理程序或用户自定义函数中构建的。
<?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"); } ?>
输出:
Custom error: [1024] A custom error has been triggered Error on line 14 in C:\webfolder\test.php Notice: A custom error has been triggered in C:\webfolder\test.php on line 21