Code QuizIntermediate try-catch block structure and basic syntax
Learn the correct syntax for a PHP try-catch block by spotting a common catch-clause mistake.
Codephp
<?php
function divide($a, $b) {
if ($b === 0) {
throw new Exception("Division by zero");
}
return $a / $b;
}
try {
echo divide(10, 0);
} catch ($e) {
echo "Error: " . $e->getMessage();
}
What is the bug in this code?