php try catch嵌套
<?php try { dsss(); throw new Exception("555"); } catch (Exception $e) { echo $e->getMessage(); // die(); // 终止异常 } function dsss() { try { $num1 = 3; $num2 = 0; if ($num2 == 0) { throw new Exception("111"); } else { $res = $num1 / $num2; } } catch (Exception $e) { echo $e->getMessage(); // die(); // 终止异常 } }
运行后 发现可以嵌套
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/19014.html