try catch throw new exception ('message')

    try {
      echo $abc + 1 . "\n";
    } catch (Exception $e) {
      echo 'Caught exception: qinqiu ',  $e->getMessage(), "\n";
      throw new Exception('try a gain');
    } finally {
      echo "Second finally.\n";
      $mess = new Exception('try a gain');
      echo $mess->getmessage();
    }

--

use exception; (manually add)
throw new expceiton('string') -- will stop the excution
只有在一个函数throw new Exception('Division by zero.');
然后在调用这个函数后,调用一个catch就可以获取到$e->getMessage()

 

--> 使用try catch throw new exception()  的 意义就在于不打扰整个系统的运行一般看到的还都能看到;

use Exception; [not exception]

  function returnfalse(){
    throw  new Exception('Division by oen middlion zero.');
//     var_dump($abc->getTrace());
//     return FALSE;
  }
  function returntrue(){
    throw  new Exception('Division by oen middlion.');
//     var_dump($abc->getTrace());
//     return FALSE;
  }

是生效的不会打乱页面只有在kint()的时候会被打印出来

是这样的,throw出什么的exception就会要相应的exception去接收 不然就报错

 

exception可以接收qexception, bexception

exception可以接收exception,

qaexception不能接收exception......

转载于:https://www.cnblogs.com/qinqiu/p/8031595.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值