php捕獲異常錯誤

//0)設置錯誤handler
set_error_handler ( 'customerror' );
set_exception_handler ( 'customexception' );
register_shutdown_function('customend');

//0)定義捕獲方法
function customerror($error_level,$error_message,$error_file,$error_line,$error_context) {
    die();//終止腳本
}
function customexception($exception) {
    echo 'hhhhh';
}
function customend() {
    if(error_get_last()) {
        var_dump(error_get_last());
    }
}

//代碼入口
(new Application())->run();


* 在「代碼入口」以前定義捕獲handlercode

相關文章
相關標籤/搜索