php调用class a{
    function construct(){
        echo "start to construct a obj
";
    }   
    function pide($a,$b)
    {   
        //exit(1);//destruct called
        return $a/$b; //destruct called when $b=0;
    }   
    function add($a,$b)
    {   
        throw new Exception ("daone");//destruct called
        return $a+$b;
    }   
    function destruct(){
        echo "start to destruct
";
    }   
}
try{
    $first = new a();
    //$r = $first->pide(4,0);
    $first->add(4,0);
}
catch(Exception $e) 
{
    echo "cath exception 
";
}从上面的例子可以看出,php(不管外面有没有try catch),直接的情况下,都会调用。  |