PHP Exception Handler Not producing any error
<p>Hy,</p>

<p>The code below give does not throw an exception as expected instead </p>

<pre><code>   &lt;?php

    class propertyObject {

    private $_properties = array('name' =&gt; null , 'dateofBirth' =&gt; null);

     function _get($propertyName)
      {
         if(!array_key_exists($propertyName, $this-&gt;_properties))
         {
  throw new Exception("Invalid Property Value"); 
 }
 if(method_exists($this,'get'.$propertyName))
  {
    return call_user_func(array($this, 'get'.$propertyName));
  }
  else 
  {
       return $this-&gt;_properties[$propertyName];
    }  
     }

     function _set($propertyName, $value)
     {
      if(!array_key_exists($propertyName, $this-&gt;_properties))
       {
        throw new Exception("The property value you are trying to set is not valid");
       }
      if(method_exists($this, 'set'.$propertyName))
       {
        return call_user_func(array($this,'set'.$propertyName));
       }
      else
       {
      return $this-&gt;_properties[$propertyName]=$value;
       }
     }

     function setdateofBirth($dob)
     {
         if(strtotime($dob) == -1)
    {
    throw new Exception ("Invalid Date of Birth. Please enter a value date");
   }
     $this-&gt;_properties['dateofBirth']=$dob;
      }    

      function sayHello()
       {
      echo "Hello! My name is $this-&gt;name and my D.O.B is $this-&gt;dateofBirth";
       }

     }

     ?&gt;
</code></pre>

<p>The above is saved as class.propertyObject.php and then called from another file test.php. The code for test.php is as follows:</p>

<pre><code> &lt;?php

   include('class.propertyObject.php');

   $newObj = new propertyObject();

   $newObj-&gt;name='Ryann';
   $newObj-&gt;dateofbirth='08/01/2009';

   $newObj-&gt;sayHello();
   $newObj-&gt;dateofBirth='hello';

?&gt;
</code></pre>

<p>Output is: Hello! My name is Ryann and my D.O.B is 08/01/2009.</p>

<p>In my opinion the last statement  $newObj->dateofBirth='hello'; should throw an exception and accordingly error message should be displayed however it does not give out any error. Moreover, I changed the value in the following $newObj->dateofbirth='08/01/2009'; to a string name such as john it outputs: Hello! My name is Ryann and my D.O.B is john. Why there is no exception message displayed for the last statement or why the function setdateofBirth($dob) does not throw any exception when non date string value is set as $dob.</p>
