php try catch嵌套

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(); // 终止异常
    }
}

运行后 发现可以嵌套

原文地址:https://www.cnblogs.com/newmiracle/p/13606133.html