PHP

How to demonstrate the multi-level inheritance in PHP | PHP programs

How to demonstrate the multi-level inheritance in PHP | PHP programs

How to demonstrate the multi-level inheritance in PHP | PHP programs

We will implement multi-level inheritance. In the multi-level inheritance, we will inherit the one base class into a derived class, and then the derived class will become the base class for another derived class.

<?php

class Base
{
    function BaseFun()
    {
        echo "BaseFun() called<br>";
    }
}

class Derived1 extends Base
{
    function Derived1Fun()
    {
        echo "Derived1Fun() called<br>";
    }
}

class Derived2 extends Derived1
{
    function Derived2Fun()
    {
        echo "Derived2Fun() called<br>";
    }
}

$dObj = new Derived2();

$dObj->BaseFun();
$dObj->Derived1Fun();
$dObj->Derived2Fun();

?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community