I am trying to run this Example #1 from this page: http://php.net/manual/en/language.exceptions.php
<?php
function inverse($x) {
if (!$x) {
throw new Exception('Division by zero.');
}
return 1/$x;
}
try {
echo inverse(5) . "
";
echo inverse(0) . "
";
} catch (Exception $e) {
echo 'Caught exception: ', $e->getMessage(), "
";
}
// Continue execution
echo "Hello World
";
?>
However instead of the desired output I get:
0.2
Fatal error: Uncaught exception 'Exception' with message 'Division by zero.'
in xxx:
7 Stack trace: #0 xxx(14): inverse(0) #1 {main} thrown in xxx on line 7
The developer environment I am using is UniServer 3.5
with PHP 5.2.3