參數說明:
Value | Constant | Description | Note |
1 | E_ERROR | 執行時期致命的錯誤 | |
2 | E_WARNING | 執行時期錯誤警告 | |
4 | E_PARSE | 編譯時的程式剖析錯誤 | |
8 | E_NOTICE | 執行時期的提醒 | |
16 | E_CORE_ERROR | PHP 引擎啟動執行時產生的致命錯誤 | |
32 | E_CORE_WARNING | PHP 引擎啟動執行時產生的警告 | since PHP 4 |
64 | E_COMPILE_ERROR | 致命的編譯時錯誤 | since PHP 4 |
128 | E_COMPILE_WARNING | 致命的編譯時警告 | since PHP 4 |
256 | E_USER_ERROR | 使用者定義的錯誤 | since PHP 4 |
512 | E_USER_WARNING | 使用者定義的警告 | since PHP 4 |
1024 | E_USER_NOTICE | 使用者定義的提醒 | since PHP 4 |
2048 | E_STRICT | 編碼標準化警告(建議如何修改以向前兼容) | since PHP 5 |
4096 | E_RECOVERABLE_ERROR | 接近致命的運行時錯誤,若未被捕獲則視同E_ERROR | since PHP 5.2.0 |
8192 | E_DEPRECATED | Run-time notices. Enable this to receive warnings about code that will not work in future versions. | since PHP 5.3.0 |
16384 | E_USER_DEPRECATED | User-generated warning message. This is like an E_DEPRECATED, except it is generated in PHP code by using the PHP function trigger_error(). | since PHP 5.3.0 |
30719 | E_ALL | 所有的錯誤、警告 | 32767 in PHP 6, 30719 in PHP 5.3.x, 6143 in PHP 5.2.x, 2047 previously |
範例:
1/0 會產生一個 WARNING 的錯誤等級,先將程式錯誤等級設為 E_ERROR ,則不會有錯誤訊息出現,因為已經被忽略了。
<?php
error_reporting(E_ERROR);
printf("%d\n", 1/0);
error_reporting(E_WARNING);
printf("%d\n", 1/0);
?>
輸出結果:
0
Warning: Division by zero in /var/www/html/error1.php on line 6
0
參考文件:
http://tw2.php.net/manual/en/errorfunc.constants.php#errorfunc.constants.errorlevels.e-error
沒有留言:
張貼留言