确定PHP脚本退出位置的最快方法 [英] Fastest way to determine where PHP script exits

查看:88
本文介绍了确定PHP脚本退出位置的最快方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设您有一个大型PHP项目,突然,当试图运行它时,您最终得到一个空白页.该脚本终止了,您想以最小的努力找到确切的位置.

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 with as little effort as possible.

是否有工具/程序/命令/IDE,可以在PHP脚本终止时告诉您脚本出口的位置?

Is there a tool/program/command/IDE that can, on PHP script termination, tell you the location of a script exit?

注意:我不能将自己的帖子标记为已接受的答案",因此请查看底部以查看解决方案.如果您提出更好的解决方案,我会将您的帖子标记为答案.

Note: I can't mark my own post as "accepted answer" so look at the bottom to see my solution. If you come up with a better solution I will mark your post as the answer.

推荐答案

从RoBorg的无效但仍然正确的答案中获得了一些启发,我在开始时使用了以下代码:

With some inspiration from the nonworking but still right-direction answer from RoBorg, I used the following code in the beginning:

function shutdown() {
    global $dbg_stack_a;
    print_r($dbg_stack_a);
}
register_shutdown_function('shutdown');

然后我创建了一个全局条件断点(全局=断点在每一行上都进行了评估),利用了它可以通过以下条件"通过eval()运行代码的事实:

And then I made a global conditional breakpoint (global = breakpoint is evaluated on each row), exploiting the fact that it can run code trough eval(), with the following "condition":

eval('
global $dbg_stack_a, $dbg_stack_b, $dbg_stack_c;
$dbg_stack_a = $dbg_stack_b;
$dbg_stack_b = $dbg_stack_c;
$dbg_stack_c = debug_backtrace();
return false;
')

可能不快,但是可以解决问题!使用此程序,我可以确定引发die()的确切文件和行位置. (此示例在NuSphere中有效.)

Probably not fast but does the trick! Using this I was able to determine the exact file and line location that raised die(). (This example works in NuSphere.)

这篇关于确定PHP脚本退出位置的最快方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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