php try catch finally on the implementation of the order of explanation

Came across implementation of finally asked, suddenly found the situation is try catch finally not used, so the current has been used to sum up:

Throws First conclusion: Internal try to perform normal internal logic of the try, catch abnormal internal logic structure is executed, but finally the implementation of the internal logic of the matter which will be executed executing the try catch internal logic (non-return)

If the return try catch has, in accordance with normal execution, and finally the execution logic, and then returns a corresponding try or catch performed in return.

If the try catch finally have a return, after executing logic finally, the call will return finally is.

<?php
class test{
    public function testTry(){
    $i = 0;
    try {
       $i= $i+1;
       return $i;
    } catch (Exception $e) {
       echo "wc";
    } finally {
       $i= $i+2;
        print_r($i);
        return "1111"; // When finally there is a return back to this, when the write-off, back into the try or catch the 
        Yung.
     }  
   }
}
 
$b = new test();
echo $b->testTry();
 
?>

  

Guess you like

Origin www.cnblogs.com/Mr-Echo/p/12128621.html