简体   繁体   English

如何放置调试点

[英]How to put debug point

I've a php file calling another php file which sometimes calls another php file to execute some actions (all through ajax). 我有一个php文件,它调用另一个php文件,该文件有时会调用另一个php文件来执行某些操作(全部通过ajax)。

What I use to do was to echo at different points to know upto where the codes are executing properly. 我要做的是在不同的点上回显,以了解代码在哪里正确执行。 But with this approach, I can keep echo-ing. 但是通过这种方法,我可以保持回声。

So how do I know upto where my code is executing?? 那么我怎么知道我的代码在哪里执行呢? Is there a tool for Google Chrome browser to detect it?? Google Chrome浏览器是否有工具可以检测到它?

Firefox的Firebug插件可让您放置实际的调试断点并逐步执行代码-调试JavaScript比回显要容易得多

In your web browser, click the wrench icon, then "Tools", then "Developer tools". 在您的Web浏览器中,依次点击扳手图标,“工具”和“开发者工具”。 You can debug and step through JavaScript, you can see a timeline of requests with the request and response headers and bodies fully inspectable, etc. You should be able to debug all your AJAX request without any additional software/plugins. 您可以调试并逐步浏览JavaScript,可以看到带有时间表的请求和响应标头以及可完全检查的正文等内容的请求时间轴。您应该能够调试所有AJAX请求,而无需任何其他软件/插件。

If you look on how to set a debugging environent with PHP, you'll find a lot of dead ends, trust me, I did. 如果您研究如何使用PHP设置调试环境,您会发现很多死胡同,相信我,我做到了。 Therefore you've got 2 choices. 因此,您有2个选择。

A: Keep echo-ing which will leave a trail of painful echo's in your code. 答:保持回声,这会在代码中留下痛苦的回声。

B: Use a logger. B:使用记录仪。 I've used for a while FirePHP , which comes as a FireBug extension and lets you send debugging messages to the browser, which is ideal for debugging Javascript based apps with heavy Ajax. 我已经使用了一段时间的FirePHP ,它是FireBug扩展,可让您将调试消息发送到浏览器,这对于使用Ajax调试基于Javascript的应用程序是理想的选择。

Hope I can help! 希望我能帮忙!

The technique you're using is called bullet tracing. 您使用的技术称为项目符号跟踪。 There's no real way to track which code executes and when within an php file (like breakpoints) but you can pinpoint points of errors on lines of code as provided by the php debugger. 没有真正的方法可以跟踪执行哪些代码以及何时在php文件中执行操作(例如断点),但是您可以在php调试器提供的代码行中查明错误点。

When AJAX requests are made, you can track the progress through XMLHttpRequest States . 发出AJAX请求后,您可以通过XMLHttpRequest States跟踪进度。 To check the headers and payload of the packets being sent, you could use Firebug in Firefox 3.6.x, Firefox 4 Beta's built-in developer console, or Google Chrome's developer console. 要检查所发送数据包的标头和有效载荷,可以在Firefox 3.6.x,Firefox 4 Beta的内置开发人员控制台或Google Chrome的开发人员控制台中使用Firebug。 (Packet sniffers also work) (数据包嗅探器也可以工作)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM