Interface in PHP OOPS

 <?php


//We can not use member variables or data memebers in interface.
//we can not make constructor function in interface.
//we can not use private or protected methods in interface.
interface a
{
    public function abc();
}
interface b
{
    public function xyz();
}
class C implements a, b
{
    public function abc()
    {
        echo "abc function called . <br>";
    }

    public function xyz()
    {
        echo "xyz function called . <br>";
    }
}

$testObject = new C();
$testObject->abc() . "<br>";
$testObject->xyz() . "<br>";

// OUTPUT :
//abc function called .
// xyz function called .
?>

Comments

Popular posts from this blog

GROUP BY Clause and HAVING Clause in PHP

Method Overriding in Traits in PHP

Mysqli database Connection and Display Table Data from Database