Fastest way to determine where PHP script exits

前端 未结 9 2413
故里飘歌
故里飘歌 2020-12-14 21:02

Say you have a large PHP project and suddenly, when attempting to run it, you just end up with a blank page. The script terminates and you want to find exactly where that is

9条回答
  •  -上瘾入骨i
    2020-12-14 22:07

    I use the following code and need no special debugging environment. Note that this might take really long; you can set the ticks count higher - that makes it faster, but blurry.

    function shutdown_find_exit()
    {
        var_dump($GLOBALS['dbg_stack']);
    }
    register_shutdown_function('shutdown_find_exit');
    function write_dbg_stack()
    {
        $GLOBALS['dbg_stack'] = debug_backtrace();
    }
    register_tick_function('write_dbg_stack');
    declare(ticks=1);
    

提交回复
热议问题