Interface

  • Interface contains only the declaration of methods.

  • If any class which implement this interface must contain the declared functions in it.

  • A class can use any interface by using the implements keyword.

  • Example :
    <?php
    
    interface Interf
    {
    public function display(); 
    }
    
    class Demo implements Interf
    {
    function show()
    {
    
    echo "first method <br/>"; 
    
    }
    
    public function display()
    {
    	
    echo "second method ";
    
    }
    }
    $obj=new Demo();
    
    $obj->show();
    
    $obj->display();
    
    ?>
    
    Output :
    first method
    second method