PHP program to call a base class constructor from the derived class

bookmark

<?php
//PHP program to call a base class constructor 
//from the derived class.
class Base
{
    function __construct()
    {
        echo "Base:constructor  called<br>";
    }
}

class Derived extends Base
{
    function __construct()
    {
        parent::__construct();
        echo "Derived:constructor  called<br>";
    }
}

$dObj = new Derived();
?>


Output
Base:constructor called
Derived:constructor called