Defining an interface : Interface « Class « PHP






Defining an interface

 
interface Nameable {
    public function getName();
    public function setName($name);
}

class Book implements Nameable {
    private $name;

    public function getName() {
        return $this->name;
    }
    
    public function setName($name) {
        return $this->name = $name;
    }
}
  
  








Related examples in the same category

1.Implement an interface
2.Different class implements one interface
3.A Sample Interface
4.Implementing Multiple Interfaces
5.Defining and Using an Interface
6.Using Type Hinting with Interfaces