Home > Article > Backend Development > PHP exception handling usage example_PHP tutorial
//Capture fatalError
function fatalErrorHandler(){
$e = error_get_last();
switch($e['type']){
case E_ERROR:
case E_PARSE :
case E_CORE_ERROR:
case E_COMPILE_ERROR:
case E_USER_ERROR:
errorHandler($e['type'],$e['message'],$e['file'],$e ['line']);
break;
}
}
$test = new Test();
////A warning error occurred here and was captured by errorHandler
$test->index();
//A fatal error occurs and the script stops running and triggers fatalErrorHandler
$test = new Tesdt();
$test->index();