The crew has the last word
Three functions with a return in try, or a throw, and a finally that may return too.
<?phpfunction answer(): string { try { return 'from try'; } finally { echo "finally runs\n"; }}function override(): string { try { return 'from try'; } finally { return 'from finally'; }}function swallow(): string { try { throw new Exception('lost'); } finally { return 'finally wins'; }}echo answer(), "\n";echo override(), "\n";echo swallow(), "\n";1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…