Interfaces in PHP

Interfaces in PHP are defined to provide a common function names to the implementers. Different implementors can implement those interfaces according to their requirements. You can say, interfaces are skeletons which are implemented by developers.

As of PHP5, it is possible to define an interface, like this −

interface Mail {
   public function sendMail();
}

Then, if another class implemented that interface, like this −

class Report implements Mail {
   // sendMail() Definition goes here
}
Scroll to Top