PHP

How to implement multiple-inheritance using the interface in PHP | PHP programs

How to implement multiple-inheritance using the interface in PHP | PHP programs

How to implement multiple-inheritance using the interface in PHP | PHP programs

We will implement multiple inheritances by inheriting a class and an interface into the derived class.

<?php

class Base
{
    public function Fun1()
    {
        printf("Fun1() called<br>");
    }
}

interface Inf
{
    public function Fun2();
}

class Derived extends Base implements Inf
{
    function Fun2()
    {
        printf("Fun2() called<br>");
    }

    function Fun3()
    {
        printf("Fun3() called<br>");
    }
}

$obj = new Derived();

$obj->Fun1();
$obj->Fun2();
$obj->Fun3();

?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community