Interfaces:
  • In interface all the method must be abstract(only define).
  • All methods declared in an interface must be public.
  • Interfaces cannot contain variables and concrete methods except constants.
  • A class can implement many interfaces and Multiple interface inheritance is possible.
  • To extend from an Interface, keyword implements is used.
Example:


interface Shape
 {
function getShape();
}

class Circle implements Shape{
public function getShape() {
return "This is Shape of the Circle\n";
}
}

class MultiInher {
public function read(Shape $s) {
$shape = $s->getShape();
//
echo $shape;
}
}

$c = new Circle();

$m = new MultiInher();
$m->read($c);