Skip to content

Instantly share code, notes, and snippets.

@saaeiddev
Created October 29, 2022 17:45
Show Gist options
  • Save saaeiddev/d68c9f171f183e26617692a8a7d13c13 to your computer and use it in GitHub Desktop.
Save saaeiddev/d68c9f171f183e26617692a8a7d13c13 to your computer and use it in GitHub Desktop.
<?php
try{
$x = 0;
$y = Inverse($x);
echo "The Inverse Of $x is $y";
}catch (Exception $e){
$y = "Undefined";
}finally{
echo "The Inverse Of $x is $y";
}
function Inverse($x){
if($x == 0){
throw new Exception("Division by Zero.");
}
return 1/$x;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment