function div($a, $b)
{
if ($b == 0)
throw new Exception('Division by zero');
return $a/$b;
}
try
{
echo div(10, 2) . "<br />";
echo div(22, 0) . "<br />";
echo div(60, 3) . "<br />";
}
catch (Exception $e)
{
echo 'Exception: ' . $e->getMessage() . '<br />';
}
echo "Countinue with the program";
/*
run:
5
Exception: Division by zero
Countinue with the program
*/