PHP restore_error_handler() 函數(shù)
PHP restore_error_handler() 函數(shù)

定義和用法
restore_error_handler() 函數(shù)恢復(fù)之前的錯(cuò)誤處理程序。
該函數(shù)用于在通過 set_error_handler() 函數(shù)改變后恢復(fù)之前的錯(cuò)誤處理程序。
該函數(shù)總是返回 TRUE。
語法
restore_error_handler()
提示和注釋
提示:之前的錯(cuò)誤處理程序可能是在內(nèi)建的錯(cuò)誤處理程序或用戶自定義函數(shù)中構(gòu)建的。
實(shí)例
<?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 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:webfoldertest.php
Notice: A custom error has been triggered in
C:webfoldertest.php on line 21
Error on line 14 in C:webfoldertest.php
Notice: A custom error has been triggered in
C:webfoldertest.php on line 21

相關(guān)文章
- PHP 變量
- PHP EOF(heredoc) 使用說明
- PHP 數(shù)據(jù)類型
- PHP 魔術(shù)常量
- PHP array() 函數(shù)
- PHP array_diff() 函數(shù)
- PHP array_diff_uassoc() 函數(shù)
- PHP array_filter() 函數(shù)
- PHP array_intersect_uassoc() 函數(shù)
- PHP array_intersect_ukey() 函數(shù)
- PHP array_reduce() 函數(shù)
- PHP array_sum() 函數(shù)
- PHP array_udiff_uassoc() 函數(shù)
- PHP array_walk() 函數(shù)
- PHP asort() 函數(shù)
- PHP list() 函數(shù)
- PHP rsort() 函數(shù)
- PHP Error 和 Logging 函數(shù)
- PHP 5 Filesystem 函數(shù)
- PHP Filter 函數(shù)