dtwye28880 2014-05-13 23:14
浏览 24
已采纳

PHP脚本调试

I'm sure this question has been asked a thousand times, and this IS a fairly general question, but I'm not looking to debug a script with errors (necessarily), but to see exactly how the script is being processed, line by line, in readable (or semi-readable) format.

The idea is to gain a good understanding of how it's playing out without actually putting it into a real-world scenario... adding PRINT_R, or VAR_DUMP echos in every possible logical location... or simply throwing every possible scenario at it in an effort to produce either a PHP error, or logical error that produces an undesired result. Of course, this will be done nonetheless, but I'd still like to see what's going on behind the scenes while still in the process of debugging and QA.

In essence, I'd like to have a tool that I can initiate at the beginning of a particular PHP function that would follow the script until completion, and produce a log file, or email, with the results. Again, NOT just the errors. I think this would be great for pre-QA, but unsure if anything like this even exists (or why it shouldn't)?

Does a tool like this exist?

  • 写回答

1条回答 默认 最新

  • dongyi1777 2014-05-13 23:23
    关注

    Yes. You might install the php extension xdebug and start profiling your application. It's possible to dump a trace of your application. Then you can load that file into cachegrind to get a decent visualization and to inspect and analyse the number of calls and the time taken. http://www.xdebug.org/docs/profiler Like you asked, this is not about error tracking, but about the execution flow and finding possible bottlenecks, which could then be optimized.

    With Xdebug it's also possible to step-debug. That means that you can execute your application in a step by step manner, while having access to all variables and their values.

    There is also VLD (vulcan logic dumper) if the question includes, to see which Opcodes are thrown around. A nice online tool for this use case is also http://3v4l.org/am3S3/vld#tabs

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 c程序不知道为什么得不到结果
  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置