Variable scope problem with super object
<p>I'm having some trouble creating a "super object" (similar to that of CodeIgniter) for a framework project I'm working on.</p>

<p>I want to make a super object that all of my other classes will run through. I did that, but it seems I am unable to use my super object's object in each of my classes without using the global keyword in every function.</p>

<p>I have something like this:</p>

<pre><code>class a
{
    function aa()
    {
        return 'class a';
    }
}

class b
{
    function bb()
    {
        $blah-&gt;a-&gt;aa();
    }
}

class superobj
{
    function loadClass($class)
    {
        $this-&gt;$class = new $class;
    }
}

class blah extends superobj
{
    function __construct()
    {
        $this-&gt;loadClass('a');
        $this-&gt;loadClass('b');
    }
}

$blah = new $blah;
</code></pre>

<p>So if I run this, I get an error because I can't access the aa method. If I put global $blah into the method bb, then it works (or at least in my real project it does, I dunno about this 5 second mockup hehe).</p>

<p>So is there any way to either make the $blah object global so that I don't need to reference it for every method, OR is there a better way to achieve what I am trying to do?</p>

<p>I'm not very good at OOP...</p>
