[Solved] Calculate Rectangle Area - PHP Function Task

  

3
Topic starter

Create a function which returns rectangle area with given width and height:

  • 3 * 4 = 12
  • 6 * 8 = 8
  • 7 * 8 = 56

A = L * W where A is the area, L is the length, W is the width, and * means multiply.

1 Answer
2

Here is my function:

<?php
 
$width = readline();
$height = readline();
 
$area = calculateArea($width, $height);
echo $area;
 
function calculateArea($paramWidth, $paramHeight) {
    return $paramWidth * $paramHeight;
}
Share: