如何调试PHP脚本?
我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。
在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?
如何调试PHP脚本?
我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。
在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?
当前回答
我使用Netbeans的XDebug和Easy XDebug FireFox插件
The add-on is essential when you debug MVC projects, because the normal way XDebug runs in Netbeans is to register the dbug session via the url. With the add-on installed in FireFox, you would set your Netbeans project properties -> Run Configuratuion -> Advanced and select "Do Not Open Web Browser" You can now set your break points and start the debugging session with Ctrl-F5 as usual. Open FireFox and right-click the Add-on icon in the right bottom corner to start monitoring for breakpoints. When the code reaches the breakpoint it will stop and you can inspect your variable states and call-stack.
其他回答
在生产环境中,我使用error_log()将相关数据记录到服务器的错误日志中。
由Derick Rethans编写的Xdebug非常好。我前段时间用过,发现安装起来不那么容易。一旦你完成了,你就不会明白没有它你是如何做到的:-)
在Zend开发者专区有一篇很好的文章(在Linux上安装似乎并不容易),甚至还有一个Firefox插件,我从来没用过。
通过简单地var_dump一些关键变量,可以很容易地找到大多数错误,但这显然取决于您开发的应用程序类型。
对于更复杂的算法,步进/断点/观察函数是非常有用的(如果没有必要)
我使用Netbeans和XDebug。 在它的网站上查看如何配置它的文档。 http://php.netbeans.org/
您可以使用Firephp作为firebug的附加组件在与javascript相同的环境中调试php。
我还使用前面提到的Xdebug来分析php。