Loading, please wait...

A to Z Full Forms and Acronyms

How to demonstrate the example of a simple interface in PHP | PHP programs

Jan 28, 2022 PHP, 1821 Views
How to demonstrate the example of a simple interface in PHP | PHP programs

How to demonstrate the example of a simple interface in PHP | PHP programs

We will create an interface that contains the declaration of functions and then implement the interface into a class with function definitions.

<?php

interface Inf
{
    public function fun1();
    public function fun2();
}

class Sample implements Inf
{
    public function fun1()
    {
        printf("fun1() called<br>");
    }
    public function fun2()
    {
        printf("fun2() called<br>");
    }
}

$obj = new Sample();

$obj->fun1();
$obj->fun2();
?>
A to Z Full Forms and Acronyms