zoukankan      html  css  js  c++  java
  • try catch throw new exception ('message')

        try {
          echo $abc + 1 . " ";
        } catch (Exception $e) {
          echo 'Caught exception: qinqiu ',  $e->getMessage(), " ";
          throw new Exception('try a gain');
        } finally {
          echo "Second finally. ";
          $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......

  • 相关阅读:
    函数间的调用关系
    二分法原理
    图片1
    C函数讲解
    图片2
    图片1
    图片2
    函数间的调用关系
    C函数讲解
    二分法原理
  • 原文地址:https://www.cnblogs.com/qinqiu/p/8031595.html
Copyright © 2011-2022 走看看