How to see errors suppressed by '@'?

前端 未结 2 1747
甜味超标
甜味超标 2021-01-17 17:39

I joined this crazy company as a Site Administrator. Now I did some changes to my db configurations which have impacted the PHP scripts execution.

Strange part is P

相关标签:
2条回答
  • 2021-01-17 18:06

    If you have Xdebug installed and enabled (in development, you should) then you can set the xdebug.scream configuration option, which disables the @-operator.

    Alternatively, the scream PECL extension also disables the @-operator (and that's all it does).

    Basically you install the extension then set the scream.enabled ini setting to true/on.

    0 讨论(0)
  • 2021-01-17 18:22

    Muted errors are still visible for the handler installed via set_error_handler. So you can just add something like this to your bootstrap file:

    set_error_handler(function ($errno, $errstr, $errfile, $errline) {
        echo "$errstr at $errfile($errline)\n";
    });
    

    or, better,

    set_error_handler(function ($errno, $errstr, $errfile, $errline) {
        throw new ErrorException($errstr, $errno, 1, $errfile, $errline);
    });
    

    which also would display the stack.

    0 讨论(0)
提交回复
热议问题