What will be the output of the following PHP 7.1 code?
function inverse($a){
if (!$a){
throw new Exception( }
return 20/$a;
}
try {
echo inverse(8). "\n";
} catch (Exception $ex) {
echo 'Exception caught: ', $ex->getMessage(), "\n";
} finally {
echo "First Example.\n";
}
try {
echo inverse(0). "\n";
} catch (Exception $ex) {
echo 'Exception Caught: ', $ex->getMessage(), "\n";
} finally {
echo "Second Example.\n";
}
echo "Learning PHP\n";
?>
Correct Answer:
2.5
First Example.
Exception Caught:Division by zero is not allowed.
Second Example.
Learning PHP
Explanation:
Note: This Question is unanswered, help us to find answer for this one
More PHP 5 MCQ Questions