php 异常捕获的坑

thinkphp 框架需要注意 书写为(Exception $e)将无效   需要写成 (\Exception $e)

try {
  throw new \Exception("Error Processing Request", 1);
} catch (\Exception $e){   //如书写为(Exception $e)将无效  
  echo "string";
  echo $e->getMessage();

可以 try{

} catch {

} catch {

}

多种异常捕获

参考:

thinkphp 要注意了

https://blog.csdn.net/linwha1990/article/details/77744216

这篇文章介绍的比较详细,值得看

https://www.cnblogs.com/zyf-zhaoyafei/p/6928149.html

猜你喜欢

转载自www.cnblogs.com/swing07/p/9491982.html
今日推荐