php调试相关技术
来源:互联网 发布:淘宝上拍卖会是真的吗 编辑:程序博客网 时间:2024/05/20 00:38
参考了IBM的一些文章: http://www.ibm.com/developerworks/cn/opensource/os-php-read/#de3
一、出错信息的显示配置
php配置(php.ini):
display_error = on
error_reporting = E_ALL
看php.ini里面的注释,error_reporting的值为以下的按位或:
; error_reporting is a bit-field. Or each number up to get desired error
; reporting level
; E_ALL - All errors and warnings (doesn't include E_STRICT)
; E_ERROR - fatal run-time errors
; E_WARNING - run-time warnings (non-fatal errors)
; E_PARSE - compile-time parse errors
; E_NOTICE - run-time notices (these are warnings which often result
; from a bug in your code, but it's possible that it was
; intentional (e.g., using an uninitialized variable and
; relying on the fact it's automatically initialized to an
; empty string)
; E_STRICT - run-time notices, enable to have PHP suggest changes
; to your code which will ensure the best interoperability
; and forward compatibility of your code
; E_CORE_ERROR - fatal errors that occur during PHP's initial startup
; E_CORE_WARNING - warnings (non-fatal errors) that occur during PHP's
; initial startup
; E_COMPILE_ERROR - fatal compile-time errors
; E_COMPILE_WARNING - compile-time warnings (non-fatal errors)
; E_USER_ERROR - user-generated error message
; E_USER_WARNING - user-generated warning message
; E_USER_NOTICE - user-generated notice message
有这样几个我觉得可能有用的例子:
; - Show all errors, except for notices and coding standards warnings
;
;error_reporting = E_ALL & ~E_NOTICE
;
; - Show all errors, except for notices
;
;error_reporting = E_ALL & ~E_NOTICE | E_STRICT
同样,也可以利用error_reporting函数在php代码中设置错误信息级别:
int error_reporting ([ int $level ] )
二、使用var_dump、print类的函数来输出调试信息
三、Advanced PHP Debugger
参考: http://www.phpx.com/man/php-zh/ref.apd.html, http://www.linuxjournal.com/article/7213
安装: 使用pear(pecl)安装
sudo pecl install apd
配置: (php.ini)
添加以下3行:
zend_extension = /absolute/path/to/apd.soapd.dumpdir = /absolute/path/to/trace/directoryapd.statement_tracing = 0
使用:
要针对哪个文件进行分析,就在文件第一行加入以下php函数:
apd_set_pprof_trace();
查看结果:
之后运行它,就会在apd.dumpdir 下生成类似pprof.25802的文件。其中25802是进程号。直接查看该文件是没用意义的,使用php自带的pprofp命令来查看,可以获得详尽的信息。
为了正确的运行pprofp命令,可能需要修改php.ini的include_path,把/usr/local/php/lib/php/加入进去,因为pprofp中require了下面的文件。
pprofp -u /var/log/php-apd/pprof.25802
[chengyi@localhost apdResult]$ pprofp -u pprof.21133.0
The report above shows time and memory usage on a per-function basis, sorted by user-time as directed by the -u option. The first few columns are execution time in seconds. The Calls column is a count of the number of times that function was executed by the script. secs/call is the average execution time of each call to that function, while cumm s/call is the cumulative time spent on that function. Then it lists memory usage and finally the name of the function itself. Notice that function call reports are truncated to 15 functions by default.
- php调试相关技术
- php 调试相关
- PHP 调试技术总结
- php调试技术
- php调试技术文档
- php调试技术
- PHP调试技术
- PHP调试技术
- PHP相关缓存技术
- PHP连接webservice调试相关
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- PHP 程序员的调试技术
- extjs学习笔记(四)带分页的grid
- 两次发布操作太快了,请等 20 秒钟再试
- Add Defect To QC from QTP that use the QCUtil.QCConnection sub
- 获取子窗口的位置 GetWindowRect
- MSSQL数据库损坏的修复命令DBCC简介
- php调试相关技术
- Oracle10g--SPFILE与PFILE【转】
- 理解devfs、sysfs、udev
- 有效授权的6个步骤 The Six Steps of Effective Delegation
- JAVA开发者最常去的20个英文网站{转载}
- MySQL配置文件my.cnf(my.ini) 例子最详细翻译
- RMAN备份恢复之BLOCKRECOVER
- my outlook configuration for my dilitech mail account
- ASP.NET中返回历史记录的代码,