Back to questions
JuniorTheoryCommon
What does the program print?
<?php
try {
echo 'a';
throw new RuntimeException('boom');
echo 'b';
} catch (Exception $e) {
echo 'c', $e->getMessage();
}
echo 'd', "\n";acboomd
- Expecting
bto be printed:throwleaves thetryblock on the spot, and the lines after it in that block never run. - Expecting the script to end after the
catchblock: a caught exception is handled, and the program goes on with the next line.
- What would the program print if the
catchnamedInvalidArgumentExceptioninstead? - Where does the program continue once a
catchblock has finished?