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; } } // Creating instances $circle = new Circle(5); $rectangle = new Rectangle(4, 6); // Calling the same method name on different objects echo "Circle Area: " . $circle->calculateArea(); // Output: Circle Area: 78.539816339745 echo "
"; echo "Rectangle Area: " . $rectangle->calculateArea(); // Output: Rectangle Area: 24 ?>