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(); // 终止异常
}
}
运行后 发现可以嵌套