dongtuan1594 2013-09-11 19:18
浏览 6
已采纳

在运行时检查自定义PHP错误处理程序

Is there any way to check, at runtime, if a custom PHP error handler has been set?

That is, the PHP function set error handler allows you to set a custom function/callback to handle PHP errors. However, there's no corresponding get_error_handler function.

Does PHP have any system for checking this at runtime? If there's no official API for doing this, is there any tricky way of determining this via code?

  • 写回答

1条回答 默认 最新

  • dongxiansi0158 2013-09-11 19:26
    关注

    You can set your own error handler, and get return value of set_error_handler - if it is null there was no error handler defined:

    $last_error_handler = set_error_handler(function(){});
    if ($last_error_handler === null) {
        restore_error_handler();
    } else {
        // Set it back to what was defined
        set_error_handler($last_error_handler);
        echo "Found";
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据