Challenge 3 — Solution Task: Create a Rectangle class with a constructor taking $width and $height, and methods getArea() and getPerimeter(). Create two rectangles with different dimensions and echo both calculated values for each, demonstrating they're independent of one another. width * $this->height; } public function getPerimeter(): float { return 2 * ($this->width + $this->height); } } $rect1 = new Rectangle(4, 6); $rect2 = new Rectangle(10, 2.5); echo "Rectangle 1 - Area: " . $rect1->getArea() . ", Perimeter: " . $rect1->getPerimeter() . "
"; echo "Rectangle 2 - Area: " . $rect2->getArea() . ", Perimeter: " . $rect2->getPerimeter(); ?> Output: Rectangle 1 - Area: 24, Perimeter: 20 Rectangle 2 - Area: 25, Perimeter: 25 Notes: - This solution uses constructor property promotion (the shorthand mentioned in the chapter's own tip-box) - adding "private" directly in front of $width and $height in the constructor's parameter list automatically creates and assigns both properties, with no separate $this->width = $width; lines needed. - $rect1 and $rect2 are entirely independent objects - each has its own $width and $height, so calling getArea() or getPerimeter() on one has no effect whatsoever on the other's stored values. - Rectangle 2 happens to have identical area and perimeter (25 and 25) purely by coincidence of the chosen dimensions - both methods are still computed completely independently from $width and $height.