如何在异常堆栈跟踪中禁用PHP切断长参数的一部分?

Aar*_*ken 15 php exception-handling exception

有时这样的事情会发生:

#0 /some/path(1): Class_Name->exception_trigger()
#1 /some/other/path(5):  get_to('/some/long/path/tha...')
Run Code Online (Sandbox Code Playgroud)

如何查看所有内容的完整参数?

Art*_*cto 12

您必须替换未捕获的异常处理程序.例:

function exception_handler($exception) {
    $i = 0;
    foreach ($exception->getTrace() as $frame) {
        echo sprintf("#%d %s(%d): %s(%s)\n",
            $i++, $frame["file"], $frame["line"],
            $frame["function"],
            implode(", ", array_map(
                function ($e) { return var_export($e, true); }, $frame["args"])));
    }
}

set_exception_handler('exception_handler');
Run Code Online (Sandbox Code Playgroud)

现在你会得到类似的东西:

#0 /home/glopes/a.php(21): a('loooooooooooooooooooooooooooooooooong argument')
#1 /home/glopes/a.php(24): b()


cbe*_*ski 5

如果您正在使用xdebug,则可以指定它吐出的变量的长度和数量.