The PHP Exception class for the system?

0

A question that came up shortly is "The PHP Exception class for the system?" , I mean, when we throw an exception in the script, does something after this exception still work?

    
asked by anonymous 21.03.2014 / 18:36

2 answers

5

Hello

According to the documentation not:

  

When an exception is thrown, code soon after the statement will not be   executed, and PHP will attempt to find the first corresponding catch block   the exception shot. If an exception is not caught, a PHP Fatal Error   will be released with a message "Uncaught Exception ...", unless   a handler has been set with set_exception_handler ().

    
21.03.2014 / 18:45
0

If you need something to be executed even if there is an exception, you need to use "finally".

example:

// O codigo abaixo vai imprimir: 1234
echo '1';
try {
    echo '2';
    throw new Exception();
} catch (Exception $e) {
    echo '3';
} finally {
    echo '4';
}

Referral link: link

    
22.03.2014 / 16:35