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?
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?
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 ().
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