<?php
//throw excepetion inside a method
function Test($count)
  {
  if($count<5)
    {
    throw new Exception("Value must be above 5");
    return true;
    }
  }

//trigger exception in a "try" block
try
  {
  Test(3);
  echo 'Number is above 5';
  }

//catch exception
catch(Exception $e)
  {
  echo 'Message: ' .$e->getMessage();
  }
?>