PHP 调试技术手册 1.0.0
黑夜路人的开源世界 / 风雪之隅 第 1 页 共 51 页
目录
1 内置 API 输出调试 .................................................................................................................................... 2
1.1 基本调试 API ............................................................................................................................................... 2
1.1.1 echo (print): ......................................................................................................................................... 2
1.1.2 printf .................................................................................................................................................... 2
1.1.3 print_r、var_dump(var_export)、debug_zval_dump ......................................................................... 3
1.2 错误控制和日志记录调试 ........................................................................................................................... 6
1.2.1 错误选项控制 .................................................................................................................................... 6
1.2.2 错误抛出和处理 ................................................................................................................................ 8
1.2.3 使用错误抑制符 ............................................................................................................................... 11
1.2.4 日志记录 ........................................................................................................................................... 11
2 浏览器调试 ............................................................................................................................................... 13
2.1 页面输出调试 ............................................................................................................................................. 13
2.2 FirePHP 调试 .............................................................................................................................................. 14
2.2.1 普通变量监测 .................................................................................................................................. 15
2.2.2 调用栈监测 ...................................................................................................................................... 17
2.2.3 监测抛出异常 .................................................................................................................................. 18
2.2.4 组显示信息 ...................................................................................................................................... 18
3 IDE 调试 .................................................................................................................................................... 19
3.1 基本常用 IDE 介绍 .................................................................................................................................... 19
3.1.1 Vim .................................................................................................................................................... 19
3.1.2 Zend Studio ....................................................................................................................................... 19
3.1.3 Eclipse ............................................................................................................................................... 21
3.1.4 NetBeans ........................................................................................................................................... 22
3.2 IDE 调试 ...................................................................................................................................................... 23
3.2.1 Zend Studio + Zend Debugger .......................................................................................................... 23
3.2.2 Eclipse (PDT) + Xdebug ................................................................................................................... 31
3.2.3 Vim + Xdebug + DBGp ..................................................................................................................... 37
4 PHP 性能调试技术.................................................................................................................................... 39
4.1 基本时间占用监测 ..................................................................................................................................... 39
4.2 使用 Xdebug 进行性能分析 .................................................................................................................... 39
4.2.1 安装配置: ...................................................................................................................................... 41
4.3 APD(Advanced PHP Debugger) .................................................................................................................. 46
4.3.1 安装配置 .......................................................................................................................................... 46
4.3.2 使用 APD ......................................................................................................................................... 46
4.4 使用 Xhprof 进行性能分析 ...................................................................................................................... 47
4.4.1 Xhprof 的优点: ............................................................................................................................. 47
5 PHP 单元测试技术 .................................................................................................................................... 51
5.1 PHPUnit ....................................................................................................................................................... 51