PHP的error_reporting錯(cuò)誤級(jí)別變量對(duì)照表
在PHP中所有的報(bào)錯(cuò)信息可以用error_reporting()這個(gè)函數(shù)來(lái)設(shè)置:
它的參數(shù)有字符串和數(shù)字兩種表示方法,共14個(gè)等級(jí),但是呢,我看使用其他數(shù)字貌似也可以,起初我以為它指的是一定的報(bào)錯(cuò)區(qū)間,后來(lái),終于發(fā)現(xiàn)了其中的規(guī)律:
現(xiàn)在,我將其總結(jié)如下:
| 數(shù)字 | 常量 | 說(shuō)明 |
| 1 | E_ERROR | 致命錯(cuò)誤,腳本執(zhí)行中斷,就是腳本中有不可識(shí)別的東西出現(xiàn) 舉例: Error:Invalid parameters. Invalid parameter name |
| 2 | E_WARNING | 部分代碼出錯(cuò),但不影響整體運(yùn)行 舉例: Warning: require_once(E:/include/config_base.php) |
| 4 | E_PARSE | 字符、變量或結(jié)束的地方寫規(guī)范有誤 舉例: Parse error: syntax error, unexpected $end in |
| 8 | E_NOTICE | 一般通知,如變量未定義等 舉例: Notice: Undefined variable: p in E:\web\index.php on line 17 |
| 16 | E_CORE_ERROR | PHP進(jìn)程在啟動(dòng)時(shí),發(fā)生了致命性錯(cuò)誤 舉例: 暫無(wú) |
| 32 | E_CORE_WARNING | 在PHP啟動(dòng)時(shí)警告(非致命性錯(cuò)誤) 舉例: 暫無(wú) |
| 64 | E_COMPILE_ERROR | 編譯時(shí)致命性錯(cuò)誤 舉例: 暫無(wú) |
| 128 | E_COMPILE_WARNING | 編譯時(shí)警告級(jí)錯(cuò)誤 舉例: 暫無(wú) |
| 256 | E_USER_ERROR | 用戶自定義的錯(cuò)誤消息 舉例: 暫無(wú) |
| 512 | E_USER_WARNING | 用戶自定義的警告消息 舉例: 暫無(wú) |
| 1024 | E_USER_NOTICE | 用戶自定義的提醒消息 舉例: 暫無(wú) |
| 2047 | E_ALL | 以上所有的報(bào)錯(cuò)信息,但不包括E_STRICT的報(bào)錯(cuò)信息 舉例: 暫無(wú) |
| 2048 | E_STRICT | 編碼標(biāo)準(zhǔn)化警告,允許PHP建議如何修改代碼以確保最佳的互操作性向前兼容性。 |
error_reporting 變量的默認(rèn)值是 E_ALL & ~E_NOTICE
開發(fā)時(shí),最佳的值為: E_ALL | E_STRICT
如果設(shè)置為:error_reporting(E_ALL | E_STRICT),則表示記錄所有的錯(cuò)誤信息
可能會(huì)導(dǎo)致網(wǎng)站出現(xiàn)一大堆的錯(cuò)誤代碼;但是對(duì)于程序員來(lái)說(shuō)應(yīng)該說(shuō)是一件好事,可以把代碼優(yōu)化到最優(yōu); 一些非致命性錯(cuò)誤雖然不影響程序的運(yùn)行,但是會(huì)加重PHP的負(fù)擔(dān).
最后,曬出英文版的對(duì)照表:
| 1 | E_ERROR | Fatal run-time errors. Errors that can not be recovered from. Execution of the script is halted |
| 2 | E_WARNING | Non-fatal run-time errors. Execution of the script is not halted |
| 4 | E_PARSE | Compile-time parse errors. Parse errors should only be generated by the parser |
| 8 | E_NOTICE | Run-time notices. The script found something that might be an error, but could also happen when running a script normally |
| 16 | E_CORE_ERROR | Fatal errors at PHP startup. This is like an E_ERROR in the PHP core |
| 32 | E_CORE_WARNING | Non-fatal errors at PHP startup. This is like an E_WARNING in the PHP core |
| 64 | E_COMPILE_ERROR | Fatal compile-time errors. This is like an E_ERROR generated by the Zend Scripting Engine |
| 128 | E_COMPILE_WARNING | Non-fatal compile-time errors. This is like an E_WARNING generated by the Zend Scripting Engine |
| 256 | E_USER_ERROR | Fatal user-generated error. This is like an E_ERROR set by the programmer using the PHP function trigger_error() |
| 512 | E_USER_WARNING | Non-fatal user-generated warning. This is like an E_WARNING set by the programmer using the PHP function trigger_error() |
| 1024 | E_USER_NOTICE | User-generated notice. This is like an E_NOTICE set by the programmer using the PHP function trigger_error() |
| 2048 | E_STRICT | Run-time notices. PHP suggest changes to your code to help interoperability and compatibility of the code |
| 4096 | E_RECOVERABLE_ERROR | Catchable fatal error. This is like an E_ERROR but can be caught by a user defined handle (see also set_error_handler()) |
| 8191 | E_ALL | All errors and warnings, except level E_STRICT (E_STRICT will be part of E_ALL as of PHP 6.0) |
相關(guān)文章
在laravel中實(shí)現(xiàn)將查詢的對(duì)象轉(zhuǎn)換為多維數(shù)組的函數(shù)
今天小編就為大家分享一篇在laravel中實(shí)現(xiàn)將查詢的對(duì)象轉(zhuǎn)換為多維數(shù)組的函數(shù),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2019-10-10
yii2使用gridView實(shí)現(xiàn)下拉列表篩選數(shù)據(jù)
這篇文章主要為大家詳細(xì)介紹了yii2使用gridView實(shí)現(xiàn)下拉列表篩選數(shù)據(jù)的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-04-04
php技術(shù)實(shí)現(xiàn)加載字體并保存成圖片
這篇文章主要介紹了php技術(shù)實(shí)現(xiàn)加載字體并保存成圖片,需要的朋友可以參考下2015-07-07
PHP網(wǎng)頁(yè)游戲?qū)W習(xí)之Xnova(ogame)源碼解讀(十一)
這篇文章主要介紹了PHP網(wǎng)頁(yè)游戲Xnova(ogame)源碼解讀的建筑頁(yè)面部分,需要的朋友可以參考下2014-06-06
php版微信公眾平臺(tái)接口開發(fā)之智能回復(fù)開發(fā)教程
這篇文章主要介紹了php版微信公眾平臺(tái)接口開發(fā)之智能回復(fù)開發(fā),結(jié)合實(shí)例形式較為詳細(xì)的分析了只能回復(fù)功能的原理與通過(guò)微信接口調(diào)用具體實(shí)現(xiàn)技巧,需要的朋友可以參考下2016-09-09
CentOS 6.3下安裝PHP xcache擴(kuò)展模塊筆記
這篇文章主要介紹了CentOS 6.3下安裝PHP xcache擴(kuò)展模塊筆記,本文包含xchache的編譯安裝、配置、測(cè)試等內(nèi)容,需要的朋友可以參考下2014-09-09
CodeIgniter記錄錯(cuò)誤日志的方法全面總結(jié)
這篇文章主要介紹了CodeIgniter記錄錯(cuò)誤日志的方法,詳細(xì)分析了CodeIgniter框架的文件結(jié)構(gòu)與相應(yīng)的功能,結(jié)合實(shí)例分析了CodeIgniter框架記錄錯(cuò)誤日志的實(shí)現(xiàn)技巧,并分析了隱藏index文件與數(shù)據(jù)傳輸?shù)燃记?總結(jié)非常全面,需要的朋友可以參考下2016-05-05

