Another "Yet another call to a member function function() on a non-object"
<p>How come a simple instantiation doesn't work? I have been doing the same method to all of the classes I created/instantiated but this is the only one that's giving me this kind of error.  </p>

<pre><code> Fatal error: Call to a member function validate_fname_and_lname() on a non-object in /homepages/......../Validate.php on line 23
</code></pre>

<p>Here's my code:</p>

<pre><code>//Class Validate
&lt;?php

require_once 'RegExp.php';

$myRegExp = new RegExp();

class Validate 
{
    //Sends each entry to corresponding RegExp function with appropriate regular expression
    function validate_form($un, $fname)
    {
        $err_counter = 0;

        if(!$this-&gt;myRegExp-&gt;validate_fname_and_lname($fname))
        {
            $error_identifier .= 'firstName+';
            ++$err_counter;
        }
    }
}


//Class RegExp
&lt;?php

class RegExp 
{
    function validate_fname_and_lname($flname)
    {
        return preg_match("/[a-zA-Z' ']{2,}/", $flname);
    }
}
</code></pre>
