如何调试PHP脚本?

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

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


当前回答

我使用了Zend Studio(5.5)和Zend平台。这就提供了适当的调试、断点/跨代码等,尽管是有代价的。

其他回答

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

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

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.

我使用内置调试器的zend studio for eclipse。与使用eclipse pdt和xdebug进行调试相比,它仍然很慢。希望他们能解决这些问题,在最近的版本中,速度有所提高,但仍然需要2-3秒。 zend firefox工具栏让事情变得非常简单(调试下一页、当前页等)。此外,它还提供了一个分析器,可以对代码进行基准测试,并提供饼状图、执行时间等。

Print_r (debug_backtrace());

或者类似的东西:-)

坦率地说,是print和print_r()的组合,以打印出变量。我知道很多人更喜欢使用其他更高级的方法,但我发现这是最容易使用的。

我要说的是,直到我在Uni做了一些微处理器编程,甚至都不会使用它,我才完全理解这一点。