代码之家  ›  专栏  ›  技术社区  ›  Aaron Yodaiken

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

  •  15
  • Aaron Yodaiken  · 技术社区  · 14 年前

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

    我怎样才能看到所有事情的全部论据?

    2 回复  |  直到 8 年前
        1
  •  12
  •   Artefacto    14 年前

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

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

    现在你会得到这样的结果:

    #0 /home/glopes/a.php(21): a('loooooooooooooooooooooooooooooooooong argument')
    #1 /home/glopes/a.php(24): b()
    
        2
  •  4
  •   cbednarski    14 年前