title: Returning a value in constructor function of a class
body: <p>So far I have a <code>PHP</code> class with the constructor</p>
  
  <pre><code>public function __construct ($identifier = NULL)
  {
   // Return me.
  if ( $identifier != NULL )
  {
    $this-&gt;emailAddress = $identifier;
    if ($this-&gt;loadUser() )
      return $this;      
    else
    {
  // registered user requested , but not found ! 
  return false;
    }
  }
  </code></pre>
  
  <p>the functionality of <code>loadUser</code> is to look up the database for a particular email address. 
  When i set the identifier to some email that i'm sure it's not in the database; the first IF is get passed, and goes to the first ELSE. here the constructor should return FALSE; but instead, it returns an object of the class with all NULL values ! </p>
  
  <p>how do i prevent this? thanks </p>
  
  <p>EDIT:</p>
  
  <p>thank you all for the answers. that was quite fast ! I see that the OOP way is to throw an Exception. So a throw one, my question changes that what should i do with the exception?? 
  php.net's manual is pretty confusing ! </p>
  
  <pre><code>    // Setup the user ( we assume he is a user first. referees, admins are   considered users too )
      try { $him = new user ($_emailAddress);
      } catch (Exception $e_u) { 
        // try the groups database
        try { $him = new group ($_emailAddress); 
        } catch (Exception $e_g) {
            // email address was not in any of them !!  
          }
      }
  </code></pre>