Home >Backend Development >PHP Tutorial > php错误处理
php异常处理
function onError($errCode, $errMesg, $errFile, $errLine) { echo "Error Occurred\n"; throw new Exception($errMesg); } function onException($e) { echo $e->getMessage(); } set_error_handler("onError"); set_exception_handler("onException"); try { $mm=0/0; echo $mm; } catch (Exception $e) { echo $e->getCode()."\n"; echo $e->getMessage()."\n"; }