php错误捕获的方法是:可以利用【try{ }catch(Exception $e){echo $e->getMessage();}】语句来捕获错误。
一般捕获错误使用的方法是:
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如何从数据库中删除数据