doushajian2018 2015-08-28 10:12
浏览 22

PHP错误查找器

I am fixing a site of php errors down to notice. They way I am doing this is by enabling error_reporting and walking through the site, spotting errors and fixing them. I have noticed however, that this way I'm missing errors that are in unseen parts of a page, ie hidden inputs, invisible divs etc. Searching the source doesn't feel very convenient nor reliable.

I thought of creating an error handler either mailing me the errors or throwing an exception. The former would create a mess, the latter will only allow to spot one error and sometimes still will require viewing the source.

The point here is there's thousands of these errors, so even saving a couple of second on each would add up to a substantial time saving.

The question is if there's software that would highlight these errors for me, for instance a FF/Chrome extension?

  • 写回答

1条回答 默认 最新

  • doulai7239 2015-08-28 10:46
    关注

    Ok, setting up a custom error handler and piping error to FirePHP seems to do the trick. This shows me error from referenced files as well.

    set_error_handler(function ($errno, $errstr, $errfile, $errline) {
        $br = php_sapi_name() == 'cli' ? '' : '<br>';
    
        switch ($errno) {
            case E_NOTICE:  $errorType = 'Notice';  break;
            case E_WARNING: $errorType = 'Warning'; break;
            default:        $errorType = 'Error';   break;
        }
    
        $message = "$errorType: $errstr $br
     in $errfile $br
     on line $errline";
        if (php_sapi_name() == 'cli') {
            throw new Exception($message);
        } else {
            \FirePHP::getInstance(true)->error($message);
        }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 单纯型python实现编译报错
  • ¥15 c++2013读写oracle
  • ¥15 c++ gmssl sm2验签demo
  • ¥15 关于模的完全剩余系(关键词-数学方法)
  • ¥15 有没有人懂这个博图程序怎么写,还要跟SFB连接,真的不会,求帮助
  • ¥15 PVE8.2.7无法成功使用a5000的vGPU,什么原因
  • ¥15 is not in the mmseg::model registry。报错,模型注册表找不到自定义模块。
  • ¥15 安装quartus II18.1时弹出此error,怎么解决?
  • ¥15 keil官网下载psn序列号在哪
  • ¥15 想用adb命令做一个通话软件,播放录音