throw不会停止代码的运行

Posted qinqiu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了throw不会停止代码的运行相关的知识,希望对你有一定的参考价值。

try {
$error = ‘Always throw this error‘;
throw new Exception($error);

// Code following an exception is not executed.
echo ‘Never executed‘;

} catch (Exception $e) {
echo ‘Caught exception: ‘, $e->getMessage(), " ";
}

echo ‘im here‘;


不管有没有catch里面的语句块, 都会顺序的执行到echo i m here 语句。

 

以上是关于throw不会停止代码的运行的主要内容,如果未能解决你的问题,请参考以下文章