the catch receive the information from the try,
the catch show the information, but I don't understand if it shows always the error or the execute code
I have these 3 examples

try {
    echo "hello";
}
catch (Exception $e) {
    echo $e->getMessage();
}
$message = "This is an exception";
$code = 46;
try {
    throw new Exception($message,$code);
} catch (Exception $e) {
    echo $e->getMessage();
}
try  {
    throw new Exception("A terrible error has occurred", 42);
}
catch (Exception $e) {
    echo "Exception ". $e->getCode(). ": ". $e->getMessage()."<br />".
        " in ". $e->getFile(). " on line ". $e->getLine(). "<br />";
}

the difference between try,catch and finally
catch shows the error and try show the message

    Not sure if this answers your question, but the code within the catch { ... } only ever gets executed if something in the preceding try { ... } block throws an exception for any reason. Therefore, any code in the try { ... } will execute normally and completely unless you either explicitly throw an exception or some function/class you are calling throws an exception. At that moment, the code being processed stops at that point and "throws" control to the applicable catch block (if there is one -- if not, your code basically just dies). Maybe this will help:

    <?php
    
    try {
      echo "In the try{} block...<br />\n";
      throw new Exception("This was thrown from the try block.");
      echo "This will not be output.<br />\n";
    } catch(Exception $e) {
      echo "We're in the catch{} block now.<br />\n";
      echo $e->getMessage()."<br />\n";
    }
    
    echo "This is after the try/catch.<br />\n";
    throw new Exception("This is an uncaught exception<br />\n");
    echo "This will never get displayed since the preceding line will kill the script.<br />\n";
    

    Test run output:

    14:27 $ php catch.php 
    In the try{} block...<br />
    We're in the catch{} block now.<br />
    This was thrown from the try block.<br />
    This is after the try/catch.<br />
    PHP Fatal error:  Uncaught Exception: This is an uncaught exception<br />
     in /Users/********/projects/catch.php:13
    Stack trace:
    #0 {main}
      thrown in /Users/********/projects/catch.php on line 13
    
      Write a Reply...