restore_error_handler() 函数恢复之前的错误处理程序。
该函数用于在通过 set_error_handler() 函数改变后恢复之前的错误处理程序。
该函数总是返回 TRUE。
restore_error_handler()
提示:之前的错误处理程序可能是在内建的错误处理程序或用户自定义函数中构建的。
<?php//custom error handler functionfunction 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 handlerset_error_handler("customError");$test=2;//trigger errorif ($test>1) { trigger_error("A custom error has been triggered"); }//restore built-in error handlerrestore_error_handler();//trigger error againif ($test>1) { trigger_error("A custom error has been triggered"); }?>
上面代码的输出如下所示:
Custom error:[1024] A custom error has been triggeredError on line 14 in C:webfoldertest.phpNotice: A custom error has been triggered in C:webfoldertest.phpon line 21