Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
21 lines (19 sloc) 420 Bytes
//create function with an exception
function checkNum($number) {
if($number>1) {
throw new Exception("Value must be 1 or below");
return true;
//trigger exception in a "try" block
try {
//If the exception is thrown, this text will not be shown
echo 'If you see this, the number is 1 or below';
//catch exception
catch(Exception $e) {
echo 'Message: ' .$e->getMessage();