Code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Simple exception</title>
</head>
<body text="#FFFF00" bgcolor="#000080">
Please enter a number in the box <br>
<form id="exception_form" method="POST" action="Simple_exception_2.php5">
<p><input type="text" name="T1" size="20"><br>
<input type="submit" value="Submit" name="B1" >
<input type="reset" value="Reset" name="B2"></p>
</form>
<?php
$y=$_POST['T1'];
if ($y=="") { exit;}
echo ("thanks for entering <br>");
if (!sqrt($y))
{
try {
//$b = 'Custom error with php5';
throw new Exception($y);
// Code following an exception is not executed.
echo 'Never executed';
} catch (Exception $earg) {
echo '<br> Caught exception: You entered : ', $earg->getMessage();
}
}
else {
// Continue execution
echo '<br>Welcome to the world of math <br>';
$b=$y;
if($b==""){ exit; } else { print('Square root of '); echo(" $b is : ");
echo (sqrt($b));}
}
?>
</body>
</html>