Error Trail · Level 2 of 8

The crew always comes

The same function runs twice: once it succeeds, once it throws. Both times it has a finally.

<?phpfunction step(bool $fail): void {    try {        echo "try\n";        if ($fail) throw new Exception('oops');        echo "ok\n";    } finally {        echo "finally\n";    }}step(false);try {    step(true);} catch (Exception $e) {    echo "caught " . $e->getMessage() . "\n";}

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…
  4. 4…
  5. 5…
  6. 6…