For Business
Login
Home
Assessments
Mytat Certificates
Community
Courses
Premium Courses
jobs
Practice
Upskilling
Projects
Help
Run »
radius = $radius; } public function calculateArea() { return pi() * $this->radius * $this->radius; } } class Rectangle extends Shape { private $length; private $width; public function __construct($length, $width) { $this->length = $length; $this->width = $width; } public function calculateArea() { return $this->length * $this->width; } } // Create objects of both classes $circle = new Circle(5); $rectangle = new Rectangle(4, 6); // Call the calculateArea method echo "Area of the circle: " . $circle->calculateArea(); // Output: Area of the circle: 78.539816339745 echo "Area of the rectangle: " . $rectangle->calculateArea(); // Output: Area of the rectangle: 24 ?>