PHP

How to demonstrate the inheritance of interfaces in PHP | PHP programs

How to demonstrate the inheritance of interfaces in PHP | PHP programs

How to demonstrate the inheritance of interfaces in PHP | PHP programs

We will inherit an interface into another interface using the "extends" keyword and then implement the derived interface into the class.

<?php


interface Inf1
{
    public function Fun1();
}
interface Inf2 extends Inf1
{
    public function Fun2();
}

class Sample implements Inf2
{
    function Fun1()
    {
        printf("Fun1() called<br>");
    }

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

$obj = new Sample();

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

?>
TutorialsLink Curator

This is an official account managed by the team TutorialsLink Community