Object Oriented Programming accessing variable values, How to?
<p>I am a learner, I have a class <strong>db</strong> to help me connect and fetch results in mySQL.</p>

<pre><code>$set = $db-&gt;get_row("SELECT * FROM users");
echo $set-&gt;name;
</code></pre>

<p>this way i use echo results outside a class.</p>

<p>Now i have created another class name <strong>user</strong> and it has this function</p>

<pre><code>public function name() {
      global $db;
      $set = $db-&gt;get_row("SELECT * FROM users");
      $this-&gt;name = $set-&gt;name;
    }
</code></pre>

<p>after initializing the class user, when i try to echo <strong>$user->name</strong> i dont get expected results.</p>

<p>Note i have declared above <strong>var $name;</strong> in class <strong>user</strong></p>
