有哪些PHP调试技巧?
时间:2021-07-01 10:21:17
帮助过:28人阅读
回复内容:
我目前遇到的最让我称赞的debug方式是:xdebug的
xdebug_start_trace();
/* 业务代码 */
xdebug_stop_trace();
1、最简单经典的var_dump()
2、配置error_log,能够解决很多疑难杂症
3、firebug + firephp或者chrome + chromephp
php调试指南:
http://heiyeluren-doc.googlecode.com/files/PHP-Debug-Manual-public.pdf挺薄的一个册子,讲的不错。
XHProf 吧,
FaceBook开源出来的神器,PHP轻量级调试工具,可在生产环境中使用。
1. Inclusive Time :包括子函数所有执行时间。
2. Exclusive Time/Self Time:函数执行本身花费的时间,不包括子树执行时间。
3. Wall Time:花去了的时间或挂钟时间。
4. CPU Time:用户耗的时间+内核耗的时间
5.Inclusive CPU:包括子函数一起所占用的CPU
6.Exclusive CPU:函数自身所占用的CPU
我比较喜欢笨方法print_r + exit来调试代码。
php 5.6 新增 phpdbg,使用方法上类似于gdb。
官方货
.gdb xdebug
xdebug
可以结合;ide 进行断点调试
phpstrom+xdebug + chrome(debug helper) or FF (easy xdebug)
macgdbp xdebug chromephp