3v4l.org

run code in 500+ PHP versions simultaneously
<?php define('DO_RETURN', false); function execute() { try { throw new \Exception('root exception'); // throws exception } catch (\Throwable $e) { echo "[catch]"; // exception is handled somehow throw $e; // and rethrown return; // never called } finally { echo "[finally]"; // finally is handed if (DO_RETURN) return; // if return is here the thrown exception is ignored and silently scratched } } execute(); // the exception was rethrown, so should be thrown after finally
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.32, 8.3.0 - 8.3.33, 8.4.1 - 8.4.24, 8.5.0 - 8.5.9
[catch][finally] Fatal error: Uncaught Exception: root exception in /in/aLqm4:7 Stack trace: #0 /in/aLqm4(19): execute() #1 {main} thrown in /in/aLqm4 on line 7
Process exited with code 255.

preferences:
83.19 ms | 1313 KiB | 4 Q