php的錯誤級別

2022-08-14 06:12:11 字數 1315 閱讀 2412

deprecated   不贊成使用,可能有漏洞可能效率低,以後的版本不支援等

notice  通知級別的錯誤

warning    警告 這個需要看**是不是**出了問題     以上三個程式仍然繼續向下執行

fatal error  致命錯誤  程式停止執行

parse error 解析錯誤了  直接掛了  程式停止執行

e_user 級別錯誤,使用者自定義錯誤;好比,我觸發trigger_error()乙個e_user_error級別錯誤,它就相當於php本身的error錯誤

順便這裡說下,找到php.ini的乙個方法,列印出phpinfo();

如圖:程式裡寫  非php.ini

php5預設級別是e_all & ~e_notice 意思是,除了notice級別的錯誤,都顯示。這在開發模式時是有必要的。

error_reporting(0);  //不顯示錯誤

error_reporting(-1); // 顯示所有錯誤

顯示出來:ini_set('display_errors','on');

<?php 

function myhandler($errorno, $errorstr

)

return

true

; }

set_error_handler('myhandler');

$a = '0';

if (intval($a)<=0)

echo 'go on_1'; echo '

';

$b = 'hi';

if(!is_numeric($b

))

echo 'go on_2'; echo '

';

這裡可以看下手冊中trigger_error()和set_error_handler()的用法。

trigger_error()觸發e_user系列的錯誤。

set_error_handler(),可以定義自己的錯誤。

mixed  set_error_handler  ( callable  $error_handler  [, int $error_types  = e_all | e_strict  ] )

$error_handler的引數   handler  ( int $errno  , string $errstr  [, string $errfile  [, int $errline  [, array $errcontext  ]]] )

$errorno是錯誤級別,比如e_user系列的...

php的錯誤級別

fatal error 致命錯誤 指令碼終止執行 e error 致命的執行錯誤,錯誤無法恢復,暫停執行指令碼 e core error php啟動時初始化過程中的致命錯誤 e compile error 編譯時致命性錯,就像由zend指令碼引擎生成了乙個e error e user error 自...

php的錯誤級別

error reporting 用於設定 php 的報錯級別並返回當前級別。php 4,php 5 函式能夠在執行時設定 error reporting 指令。php 有諸多錯誤級別,使用該函式可以設定在指令碼執行時的級別。如果沒有設定可選引數 level,error reporting 僅會返回當...

php錯誤級別

php.ini檔案中的error reporting引數 error reporting可以設定的引數如下 錯誤報告是位欄位。可以將數字加起來得到想要的錯誤報告等級。e all 所有的錯誤和警告 不包括 e strict e error 致命性的執行時錯誤 e warning 執行時警告 非致命性錯...