PHP

How to implement multiple interfaces in the same class in PHP | PHP programs

How to implement multiple interfaces in the same class in PHP | PHP programs

How to implement multiple interfaces in the same class in PHP | PHP programs

 We will create two interfaces that contain the declaration of functions and then we will implement the interfaces in the same class.

<?php

interface Inf1
{
    public function fun1();
}

interface Inf2
{
    public function fun2();
}

class Sample implements Inf1, Inf2
{
    public function fun1()
    {
        printf("fun1() called<br>");
    }
    public 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