php: 不能嵌套try-catch-fnally,否则执行时间过长

php不能try-catch-fnally里面在嵌套try-catch-fnall,否则本来执行时间不长的程序,会被执行更长时间,这是php的bug吗?

如:

      try{
          代码块
        }catch (\Exception $e)
        {
            echo get_class($e), ": ", $e->getMessage(), "\n";
            echo " File=", $e->getFile(), "\n";
            echo " Line=", $e->getLine(), "\n";
            echo $e->getTraceAsString();
        }finally{
           try{
             代码块
           }catch (\Exception $e)
           {
            echo get_class($e), ": ", $e->getMessage(), "\n";
            echo " File=", $e->getFile(), "\n";
            echo " Line=", $e->getLine(), "\n";
            echo $e->getTraceAsString();
           }finally{
              代码块
           }
        }

  应该改成:

         try{
             代码块
           }catch (\Exception $e)
           {
            echo get_class($e), ": ", $e->getMessage(), "\n";
            echo " File=", $e->getFile(), "\n";
            echo " Line=", $e->getLine(), "\n";
            echo $e->getTraceAsString();
           }finally{
              代码块
           }

            try{
             代码块
           }catch (\Exception $e)
           {
            echo get_class($e), ": ", $e->getMessage(), "\n";
            echo " File=", $e->getFile(), "\n";
            echo " Line=", $e->getLine(), "\n";
            echo $e->getTraceAsString();
           }finally{
              代码块
           }

  

 

posted @   穆晟铭  阅读(2197)  评论(0编辑  收藏  举报
努力加载评论中...
点击右上角即可分享
微信分享提示