PHP restore_error_handler() 函数用法及示例 - PHP教程

由网友 大卫 发布 阅读 2

PHP restore_error_handler() 函数用法及示例 - PHP教程

PHP Error & Loggings 参考手册

restore_error_handler()函数还原之前的错误处理函数

语法

bool restore_error_handler ( void );

定义和用法

 在使用 set_error_handler() 改变错误处理函数之后,此函数可以 用于还原之前的错误处理程序(可以是内置的或者也可以是用户所定义的函数)。

参数

序号参数及说明
1

void

无需参数

返回值

此函数始终返回TRUE。

在线示例

以下是此函数的用法, 如果 unserialize() 导致了一个错误,接下来 会恢复原来的错误处理函数。 

<?php
   function unserialize_handler($errno, $errstr) {
      echo "无效的hello值。\n";
   }
   
   $hello = 'abc';
   set_error_handler('unserialize_handler');
   
   $original = unserialize($hello);
   restore_error_handler();
?>
测试看看‹/›

这将产生以下结果-

无效的hello值。

PHP Error & Loggings 参考手册

PHP preg_replace_callback() PHP preg_match()