如何调试PHP脚本?

我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。

在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?


当前回答

在生产环境中,我使用error_log()将相关数据记录到服务器的错误日志中。

其他回答

Komodo IDE works well with xdebug, even for the remore debugging. It needs minimum amount of configuration. All you need is a version of php that Komodo can use locally to step through the code on a breakpoint. If you have the script imported into komodo project, then you can set breakpoints with a mouse-click just how you would set it inside eclipse for debugging a java program. Remote debugging is obviously more tricky to get it to work correctly ( you might have to map the remote url with a php script in your workspace ) than a local debugging setup which is pretty easy to configure if you are on a MAC or a linux desktop.

手动调试对我来说通常更快——var_dump()和debug_print_backtrace()是你需要用来武装你的逻辑的所有工具。

由Derick Rethans编写的Xdebug非常好。我前段时间用过,发现安装起来不那么容易。一旦你完成了,你就不会明白没有它你是如何做到的:-)

在Zend开发者专区有一篇很好的文章(在Linux上安装似乎并不容易),甚至还有一个Firefox插件,我从来没用过。

我使用Netbeans和XDebug。 在它的网站上查看如何配置它的文档。 http://php.netbeans.org/

PhpEdit有一个内置调试器,但我通常最终使用echo();和print_r ();老式的方式!!