PHP Debug

配置 php.ini

; Default
error_reporting = E_ALL
display_errors = On

剔除无害提示

error_reporting = E_ALL & ~E_NOTICE
; E_ALL             - All errors and warnings (doesn't include E_STRICT)
; E_ERROR           - fatal run-time errors
; E_RECOVERABLE_ERROR  - almost 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

在脚本中设置

error_reporting(E_ALL); ini_set('display_errors','On');

在 Apahche 中设置

php_flag display_errors on php_value error_reporting 2039

这会覆盖在 php.ini 文件中为 display_errors 已经设置的标志,以及 error_reporting 的值。值 2039 代表 E_ALL & ~E_NOTICE。如果愿意采用 E_ALL,请把值设为 2047。

参见:

[PDF] PHP 调试技术手册 PHP 程序员的调试技术