Fastest way to determine where PHP script exits

前端 未结 9 2303
故里飘歌
故里飘歌 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条回答
  • 2020-12-14 21:53

    Make sure that errors are displayed in your development environment (not production).

    0 讨论(0)
  • 2020-12-14 22:05

    xdebug has a nice trace feature that'll allow you to see all the entire trace of your php app execution and it should give you give clue as to where your exit is.

    but for the quick and dirty solution a grep/find as mentioned above will do rightly.

    0 讨论(0)
  • 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);
    
    0 讨论(0)
提交回复
热议问题