我有這樣的代碼,如何可以設置error_handler所有功能。現在只有當錯誤發生在foo1 & foo2之外時,纔會調用error_handler。全局設置error_handler
set_error_handler('error_handler',-1 & ~E_NOTICE & ~E_USER_NOTICE);
function error_handler($exception) {
// log the error
}
function foo1(){
throw new Exception("Error validating user input.");
exit(0);
}
function foo2(){
throw new Exception("Error validating user input.");
exit(0);
}
這兩個'出口(0);'就沒有任何意義。該代碼從未執行。另外你的'error_handler'函數的參數不是真的正確。 – hakre