Source Code:
(back to article)
<?php function divide($dividend, $divisor) { if ($divisor == 0) { throw new Exception("Cannot divide by zero." . PHP_EOL); } return $dividend / $divisor; } try { $result = divide(10, 0); echo $result; } catch (Exception $e) { echo "Error: " . $e->getMessage(); } finally { echo "Done."; }
Result:
Report an issue