您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php错误捕获的方法是什么

2024/2/26 8:39:43发布19次查看
php错误捕获的方法是:可以利用【try{ }catch(exception $e){echo $e->getmessage();}】语句来捕获错误。
一般捕获错误使用的方法是:
(学习视频分享:java视频教程)
try{...}catch(exception $e){echo $e->getmessage();}
或者
set_exception_handler(function ($exception) {echo $exception->getmessage();});
举例:
<?phpfunction test(){ throw new exception('参数错误');}try{ //如果catch没有捕获到,才会执行到这里 set_exception_handler(function ($exception) { echo $exception;//exception 'exception' with message '参数错误' in /www/web/...(一堆信息) echo '<br>'; echo $exception->getmessage();//参数错误 }); test();}catch(exception $e){ echo $e->getmessage();//参数错误}
set_exception_handler函数设置用户自定义的异常处理函数,用于没有用 try/catch 块来捕获的异常。
相关推荐:php培训
以上就是php错误捕获的方法是什么的详细内容。
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product