如何调试PHP脚本?
我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。
在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?
如何调试PHP脚本?
我知道基本的调试,如使用错误报告。PHPEclipse中的断点调试也非常有用。
在phpStorm或任何其他IDE中调试的最佳方法(就快速和简单而言)是什么?
当前回答
XDebug对于开发至关重要。我安装它之前任何其他扩展。它为您提供任何错误的堆栈跟踪,您可以轻松地启用分析。
使用var_dump()可以快速查看数据结构。不要使用print_r(),因为你必须用<pre>包围它,而且它一次只打印一个var。
<?php var_dump(__FILE__, __LINE__, $_REQUEST); ?>
对于一个真正的调试环境,我发现最好的是Komodo IDE,但它要花费$$。
其他回答
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.
Nusphere也是一个很好的php调试器 nusphere
我使用了Zend Studio(5.5)和Zend平台。这就提供了适当的调试、断点/跨代码等,尽管是有代价的。
我使用Netbeans和XDebug。 在它的网站上查看如何配置它的文档。 http://php.netbeans.org/
Print_r (debug_backtrace());
或者类似的东西:-)