PHP5 variable scope and class construction
<p>I'm having problems with accessing variables from my classes...</p>

<pre><code>class getuser {
    public function __construct($id) {
        $userquery = "SELECT * FROM users WHERE id = ".$id."";
        $userresult = mysql_query($userquery);
        $this-&gt;user = array();
        $idx = 0;
        while($user = mysql_fetch_object($userresult)){
           $this-&gt;user[$idx] = $user;
           ++$idx;
        }
    }
}
</code></pre>

<p>I'm setting this class in a global 'classes' file, and later on I pass through a user id into the following script:</p>

<pre><code>$u = new getuser($userid);

    foreach($u-&gt;user as $user){
        echo $user-&gt;username;
    }
</code></pre>

<p>I'm hoping that this will give me the name of the user but it's not, where am I going wrong?!</p>

<p>Thanks</p>
