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......

posted @ 2017-12-13 10:27  qqisnow2021  阅读(491)  评论(0编辑  收藏  举报