是否执行了throw()和catch()之间的代码?

Eri*_*ney -3 php try-catch throw

好的,所以我是错误处理的新手,我已经看到了一些例子,但我还没有看到这个问题的答案.我将使用一些真正的基本示例代码来显示我在问什么.

if(some condition){
    throw Exception()
  }

  //Some random code in between
  echo "Code between throw() and Catch()";

catch(Exception $e){
//handle the caught exception
}
Run Code Online (Sandbox Code Playgroud)

所以基本上,我的问题是 - 如果if()中的条件导致抛出异常,随机echo语句会执行,还是会跳过并直接进入异常的catch()?

Joh*_*nde 5

从手册:

抛出异常时,不会执行语句后面的代码,PHP将尝试查找第一个匹配的catch块