Down the stairs
handle() calls save(), which calls load(), which throws. Only handle() has a catch.
<?phpfunction load(): void { echo "load starts\n"; throw new RuntimeException('disk full'); echo "load ends\n";}function save(): void { echo "save starts\n"; load(); echo "save ends\n";}function handle(): void { try { save(); echo "handle saved\n"; } catch (RuntimeException $e) { echo "caught: " . $e->getMessage() . "\n"; } echo "handle goes on\n";}handle();1. Predict the output
Tap the lines in the order you think they print.
- 1…
- 2…
- 3…
- 4…