Subject: PHP

Parameterized Constructor

  • Create a class Rectangle with properties: length and width.
  • Write a parameterized constructor to initialize the properties.
  • Add a method calculateArea() to return the rectangle's area.
  • Create an object with specific dimensions and display the area.

Select file or drag and drop

PNG, JPG, SVG

Preview