2014-03-24 55 views
1

如果我排除error_reporting()E_WARNING錯誤 - error_reporting(E_ALL & ~E_WARNING)將我的自定義錯誤處理程序與set_error_handler('error_handler')被調用PHP警告錯誤註冊?確實未納入的error_reporting的set_error_han dler捕獲錯誤()

我問這是因爲存在的Kohana框架下面的代碼:

public static function error_handler($code, $error, $file = NULL, $line = NULL) 
{ 
    if (error_reporting() & $code) 
    { 
     // This error is not suppressed by current error reporting settings 
     // Convert the error into an ErrorException 
     throw new ErrorException($error, $code, 0, $file, $line); 
    } 

    // Do not execute the PHP error handler 
    return TRUE; 
} 

,檢查觸發功能是否應該處理if (error_reporting() & $code)而我希望的功能error_hanlder被觸發永遠的錯誤那不應該被處理。

回答

0

我想我已經找到了自己的答案(來自here):

It is important to remember that the standard PHP error handler is completely bypassed for the error types specified by error_types unless the callback function returns FALSE. error_reporting() settings will have no effect and your error handler will be called regardless - however you are still able to read the current value of error_reporting and act appropriately. Of particular note is that this value will be 0 if the statement that caused the error was prepended by the @ error-control operator.

的error_reporting()的設置不會有任何效果,你的錯誤處理程序將被稱爲無關