Loading, please wait...

A to Z Full Forms and Acronyms

How to demonstrate the single inheritance in PHP | PHP programs

Jan 27, 2022 PHP, 2085 Views
How to demonstrate the single inheritance in PHP | PHP programs

How to demonstrate the single inheritance in PHP | PHP programs

We will implement single inheritance. In the single inheritance, we will inherit the one base class into a single derived class. We will use the extends keyword to implement inheritance.

<?php

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

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

$dObj = new Derived();

$dObj->BaseFun();
$dObj->DerivedFun();

?>
A to Z Full Forms and Acronyms