<?php
function checkNum($num) {
if($num<10) {
throw new Exception("Value must be more than 10");
}
return true;
}
try {
checkNum(2);
// if exception is not thrown
echo 'Exception not thrown';
}
//catch exception
catch(Exception $e) {
echo 'Got You! Exception throw: ' .$e->getMessage();
}
?>