restore_error_handler() 函數是一個內置 PHP 函數,可幫助恢複錯誤處理函數的先前版本。
用法:
restore_error_handler(): bool
參數:該函數不接受任何參數。
返回值:該函數將始終返回“true”。
示例 1:此示例代碼演示了restore_error_handler()函數。
PHP
<?php
// Set a custom error handler
function custom_error_handler($errno,
$errstr, $errfile, $errline) {
echo "Error: $errstr\n";
}
set_error_handler('custom_error_handler');
echo $age ;
// Restore the default error handler
restore_error_handler();
// Generate another error
echo $access_granted ;
?>
輸出:
Error: Undefined variable $age PHP Warning: Undefined variable $access_granted
示例 2:此示例代碼還演示了restore_error_handler()函數。
PHP
<?php
function myownHandler($errno){
echo "Custom Error on line no = ".$errno ;
}
set_error_handler("myownHandler");
$value = 2 ;
if($value >1){
echo "A custom error triggered" ;
}
restore_error_handler();
if($value >2){
echo "A customer error triggered";
}
?>
輸出:
A custom error triggered
參考: https://www.php.net/manual/en/function.restore-error-handler.php
相關用法
- PHP restore_error_handler()用法及代碼示例
- PHP restore_exception_handler()用法及代碼示例
- PHP reset()用法及代碼示例
- PHP readfile()用法及代碼示例
- PHP rename()用法及代碼示例
- PHP rewind()用法及代碼示例
- PHP realpath_cache_get()用法及代碼示例
- PHP readdir()用法及代碼示例
- PHP realpath( )用法及代碼示例
- PHP rewinddir()用法及代碼示例
- PHP read_exif_data()用法及代碼示例
- PHP require()和include()的區別用法及代碼示例
- PHP require()和require_once()的區別用法及代碼示例
- PHP readline_add_history()用法及代碼示例
- PHP readline()用法及代碼示例
- PHP realpath_cache_size()用法及代碼示例
- PHP round()用法及代碼示例
- PHP rmdir()用法及代碼示例
- PHP rad2deg()用法及代碼示例
- PHP rand()用法及代碼示例
- PHP random_int()用法及代碼示例
- PHP range()用法及代碼示例
- PHP rawurldecode()用法及代碼示例
- PHP rawurlencode()用法及代碼示例
- PHP rsort()用法及代碼示例
注:本文由純淨天空篩選整理自neeraj3304大神的英文原創作品 PHP restore_error_handler() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。