Created
October 13, 2023 09:39
-
-
Save rafaelmaeuer/43e16f6382e85b2819291d0af9b74431 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment