Can a class instantiate another class? (PHP)
<p>I tried this and I get an error when I try to instantiate class "first" inside of class "second".</p>

<p>The commented sections inside of class "second" cause errors.</p>

<pre><code>class first {
    public $a;

    function __construct() {
        $this-&gt;a = 'a';
    }
}

class second {
    //$fst = new first();
    //public showfirst() {
        //$firsta = $this-&gt;first-&gt;a;
    //  echo "Here is first \$a: " . $firsta;
    //}
}
</code></pre>

<p>EDIT:</p>

<p>This results in a server error even though all I have in class "second" is the instantiation of class "first".</p>

<pre><code>class second {
    $fst = new first();
    //public showfirsta() {
    //  $firsta = $this-&gt;fst-&gt;a;
    //  echo "Here is first \$a: " . $firsta;
    //}
}
</code></pre>
