<?php
interface Shape {
public function getArea();
}
interface Color {
public function getColor();
}
class Circle implements Shape, Color {
private $radius;
private $color;
public function __construct($radius, $color) {
$this->radius = $radius;
$this->color = $color;
}
public function getArea() {
return pi() * pow($this->radius, 2);
}
public function getColor() {
return $this->color;
}
}
$circle = new Circle(5, "red");
echo "Area of circle is: " . $circle->getArea() . "\n";
echo "Color of circle is: " . $circle->getColor();
?>
Shape
` and `Color
`, and a class `Circle
` that implements both of these interfaces. The `Circle
` class has two private attributes `$radius
` and `$color
`, and two methods `getArea()
` and `getColor()
` that implement the methods defined in the `Shape
` and `Color
` interfaces, respectively. Circle
` class and call its `getArea()
` and `getColor()
` methods to get the area and color of the circle, respectively. The output of the program will be :Area of circle is: 78.539816339745
Color of circle is: red