首頁  >  文章  >  後端開發  >  php如何查看錯誤

php如何查看錯誤

coldplay.xixi
coldplay.xixi原創
2020-10-05 13:13:133716瀏覽

php檢視錯誤的方法:1、透過設定【php.ini】中的參數設定PHP的錯誤等級可以在php.ini適當的位置增加一行;2、透過PHP函數【error_reporting】設定PHP報錯級別。

php如何查看錯誤

php查看錯誤的方法:

一、透過設定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

#;error errors ,except for notices

;error_reporting=E_ALL&~E_NOTICE|E_STRICT

;-Show only errors

#;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_##;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_##;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_##ERROR_ERROR #;-Show all errors except for notices and coding standards warnings

;error_reporting=E_ALL&~E_NOTICE

#CODE:[COPY]

##;Examples:

##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=;error_reporting=; E_ALL&~E_NOTICE|E_STRICT

;-Show only errors

;error_reporting=E_COMPILE_ERROR|E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR #E_RECOVERABLE_ERROR|E_ERROR|E_CORE_ERROR#n 可以#vallv-S how

;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 報告的錯誤訊息了

想了解更多編程學習,敬請關注
php培訓

欄位!
#

以上是php如何查看錯誤的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn