首頁  >  文章  >  後端開發  >  php開啟和關閉錯誤提示的方法介紹

php開啟和關閉錯誤提示的方法介紹

尚
轉載
2020-03-09 10:29:392822瀏覽

php開啟和關閉錯誤提示的方法介紹

php錯誤提示開啟關閉有兩種方式,一種是在php.ini設定檔中設定。另一種是在php檔案中利用函數ini_set()和error_reporting()設定。

推薦:《php訓練

1、在php.ini找到 display_errors,設定錯誤提示的開啟與關閉,off時關,on時開。同時設定error_reporting的值代表錯誤的等級。

一些常用值

 E_ALL (Show all errors, warnings and notices including coding standards.)全部錯誤

 E_ALL & ~E_NOTICE  (Show all errors,

 E_ALL & ~E_NOTICE  (Show all errors,

 E_ALL & ~E_NOTICE  (Show all errors,

# E_ALL & ~E_NOTICE  (Show all errors,

"except for notices)除通知外,全部錯誤

2、如果不能修改php.ini文件,php還提供了相關的函數來動態的配置。

ini_set('display_errors','off');關閉錯誤提示。

ini_set('display_errors','on');開啟錯誤提示。

error_reporting(E_ALL & ~E_NOTICE)設定錯誤等級。

常用的一些框架,或cms系統都是透過這兩個函數來控制php錯誤的顯示。

微擎當中的實作

define('DEVELOPMENT', $_W['config']['setting']['development'] == 1);
if(DEVELOPMENT) {
ini_set('display_errors', '1');
error_reporting(E_ALL ^ E_NOTICE);
} else {
error_reporting(0);
}
織夢

include/common.inc.php
###更多程式相關內容,請關注php中文網###程式教學###欄位! ###

以上是php開啟和關閉錯誤提示的方法介紹的詳細內容。更多資訊請關注PHP中文網其他相關文章!

陳述:
本文轉載於:csdn.net。如有侵權,請聯絡admin@php.cn刪除