php捕捉错误的方法:1、使用“try catch”语句捕获错误;2、通过“set_exception_handler”方法捕获错误,该方法用于设置用户自定义的异常处理函数。
PHP错误捕获处理 一般捕获错误使用的方法是: try{
...
}catch(Exception $e){
echo $e->getMessage();
} 或者 set_exception_handler(function ($exception) {
echo $exception->getMessage();
}); 示例: ';
echo $exception->getMessage();//参数错误
});
test();
}catch(Exception $e){
echo $e->getMessage();//参数错误
} set_exception_handler — 设置用户自定义的异常处理函数,用于没有用 try/catch 块来捕获的异常。 更多相关知识,请访问PHP中文网! 以上就是php如何捕捉错误的详细内容,更多请关注 模板之家(www.mb5.com.cn) 其它相关文章! |