KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
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) . "\n"; echo inverse(0) . "\n"; } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } // Continue execution echo "Hello World\n"; ?> 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
Tags (comma-separated)
Save Edits
Cancel