壹、通過配置php.ini中的參數設置PHP的報錯級別可以在php.ini中適當的位置增加壹行
error_reporting=E_ALL
CODE:[COPY]
error_reporting=E_ALL
註:php.ini中實現給出了壹些例子,比如我本地的php.ini中就有如下
;Examples:
;-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
;-Show only errors
;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
;-Show all errors except for notices and coding standards warnings
;error_reporting=E_ALL&~E_NOTICE
CODE:[COPY]
;Examples:
;-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
;-Show only errors
;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR
;-Show all errors except for notices and coding standards warnings
;error_reporting=E_ALL&~E_NOTICE
我只要在這些行代碼的下面增加error_reporting=E_ALL然後重新啟動web服務就可以了
二、通過PHP函數error_reporting設定PHP報錯級別
如果妳無權修改php.ini中的參數配置,妳可以通過這個函數來設置報錯級別。
error_reporting()函數使用方法
error_reporting(report_level)
如果參數level未指定,當前報錯級別將被返回。
任意數目的以上選項都可以用?或?來連接(用OR或|),這樣可以報告所有需要的各級別錯誤。例如,下面的代碼關閉了用戶自定義的錯誤和警告,執行了某些操作,然後恢復到原始的報錯級別:
//禁用錯誤報告
error_reporting(0);
//報告運行時錯誤
error_reporting(E_ERROR|E_WARNING|E_PARSE);
//報告所有錯誤
error_reporting(E_ALL);
CODE:[COPY]
//禁用錯誤報告
error_reporting(0);
//報告運行時錯誤
error_reporting(E_ERROR | E_WARNING | E_PARSE);
//報告所有錯誤
error_reporting(E_ALL);
那麽我們就可以把論壇裏的include/common.inc.php文件裏的
error_reporting(0);
CODE:[COPY]
error_reporting(0);
修改成
error_reporting(E_ALL);
CODE:[COPY]
error_reporting(E_ALL);
然後保存,這樣就可以看到 PHP 報告的錯誤信息了