如何调试PHP脚本?
我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。
在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?
如何调试PHP脚本?
我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。
在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?
当前回答
通过简单地var_dump一些关键变量,可以很容易地找到大多数错误,但这显然取决于您开发的应用程序类型。
对于更复杂的算法,步进/断点/观察函数是非常有用的(如果没有必要)
其他回答
集成的调试器,可以在逐步执行代码时观察变量值的变化,这真的很酷。但是,它们确实需要在服务器上安装软件,并在客户机上进行一定数量的配置。两者都需要定期维护以保持良好的工作状态。
print_r易于编写,并保证在任何设置中都能工作。
我使用了Zend Studio(5.5)和Zend平台。这就提供了适当的调试、断点/跨代码等,尽管是有代价的。
您可以使用Firephp作为firebug的附加组件在与javascript相同的环境中调试php。
我还使用前面提到的Xdebug来分析php。
PhpEdit有一个内置调试器,但我通常最终使用echo();和print_r ();老式的方式!!
For the really gritty problems that would be too time consuming to use print_r/echo to figure out I use my IDE's (PhpEd) debugging feature. Unlike other IDEs I've used, PhpEd requires pretty much no setup. the only reason I don't use it for any problems I encounter is that it's painfully slow. I'm not sure that slowness is specific to PhpEd or any php debugger. PhpEd is not free but I believe it uses one of the open-source debuggers (like XDebug previously mentioned) anyway. The benefit with PhpEd, again, is that it requires no setup which I have found really pretty tedious in the past.