How to inherit class name in PHP?
<p>How can I get the class name of the child class instead of the parent class? Both print <code>a</code>, but it should print <code>b</code> in the second <code>var_dump()</code>.</p>

<pre><code> &lt;?php
    class a
    {
        public $name;

        public function __construct()
        {
            $this-&gt;name=get_class();
        }
    }

    class b extends a
    {
        public function b()
        {
            parent::__construct();
        }
    }

    $a= new a();
    $b=new b();

    var_dump($a); //prints a
    var_dump($b); //prints a, i want to be printed b here
?&gt;
</code></pre>
