fork download
  1. <?php
  2.  
  3. function throwWithFinalAndCatch() {
  4. try {
  5. echo 'One'.PHP_EOL;
  6. throw new \Exception();
  7. } catch( \Exception $e ) {
  8. $exception = $e;
  9. } finally {
  10. echo 'Two'.PHP_EOL;
  11. }
  12.  
  13. if ( $exception ) {
  14. throw $exception;
  15. }
  16. }
  17.  
  18.  
  19. function throwWithFinal() {
  20. try {
  21. echo 'One'.PHP_EOL;
  22. throw new \Exception();
  23. } finally {
  24. echo 'Two'.PHP_EOL;
  25. }
  26. }
  27.  
  28. try {
  29. throwWithFinalAndCatch();
  30. } catch (\Exception $e) {}
  31.  
  32.  
  33. try {
  34. throwWithFinal();
  35. } catch (\Exception $e) {}
  36.  
  37.  
Success #stdin #stdout 0.02s 26100KB
stdin
Standard input is empty
stdout
One
Two
One
Two