Error Trail · Level 5 of 8

Two families of trouble

Divide by zero, a wrong argument type and a plain exception, caught by Exception and Throwable.

<?phpfunction half(int $n): int { return intdiv($n, 2); }$tests = [    fn() => intdiv(1, 0),    fn() => half('ten'),    fn() => throw new Exception('plain'),];foreach ($tests as $t) {    try {        $t();    } catch (Exception $e) {        echo "Exception: ", $e->getMessage(), "\n";    } catch (Throwable $e) {        echo get_class($e), " is an Error\n";    }}

1. Predict the output

Tap the lines in the order you think they print.

  1. 1…
  2. 2…
  3. 3…