如何禁用PHP在异常堆栈跟踪中切断长参数的部分? [英] How to disable PHP cutting off parts of long arguments in exception stack trace?

查看:135
本文介绍了如何禁用PHP在异常堆栈跟踪中切断长参数的部分?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有时候会发生这种情况:

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

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

解决方案

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

  function exception_handler($ exception){
$ i = 0;
foreach($ exception-> getTrace()as $ frame){
echo sprintf(#%d%s(%d):%s(%s)\\\

$ i ++,$ frame [file],$ frame [line],
$ frame [function],
implode(,,array_map(
function ($ e){return var_export($ e,true);},$ frame [args])));
}
}

set_exception_handler('exception_handler');

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

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


Sometimes things like this happen:

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

How do I get to see the full arguments for everything?

解决方案

You'll have to replace the uncaught exception handler. Example:

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');

Now you'll get something like:

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

这篇关于如何禁用PHP在异常堆栈跟踪中切断长参数的部分?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆