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 Vue3 大型图片数据拖动排序
  • ¥15 划分vlan后不通了
  • ¥15 GDI处理通道视频时总是带有白色锯齿
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)
  • ¥15 自适应 AR 模型 参数估计Matlab程序
  • ¥100 角动量包络面如何用MATLAB绘制
  • ¥15 merge函数占用内存过大
  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大