Using implements keyword we can cam implement an interface with a Class. An interface can define method names and arguments, but not the contents of the methods
Define using interface keyword
See the below example on Interface.
<?php
interface OnlineCalculator {
public function getArea();
}
// Get the Area of a Circle
class Circle implements OnlineCalculator {
private $radius;
public function __construct($radius){
$this -> radius = $radius;
}
public function getArea(){
return $this -> radius * $this -> radius * pi();
}
}
$mycircle = new Circle(3);
echo $mycircle->getArea();
?>