/*
throw new Exception($error_message);
*/
function checkZero($n) {
if($n == 0) {
throw new Exception("Value must be > 0");
}
return true;
}
try {
checkZero(1);
echo 'If you see this line, the exception is not thrown';
}
catch(Exception $e) {
echo 'Error Message: ' .$e->getMessage();
}
/*
run:
If you see this line, the exception is not thrown
*/