Q:

Area of a Rectangle in Php

0

Area of a rectangle is calculated by the mathematical formula,

 

Length ∗ Breadth = Area  

Logic:

  • Take two variables.
  • Multiply both of them.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Area of Rectangle in PHP

Program to calculate area of rectangle with length as 14 and width as 12 is shown.

Example:

<?php  
 $length = 14;  
 $width = 12;  
 echo "area of rectangle is $length * $width= " . ($length * $width) . "<br />";  
  ?>  

Output:

 

Area of Rectangle with Form in PHP

Program to calculate area of rectangle by inserting values in the form is shown.

Example:

<html>  
<body>  
<form method = "post">   
Width: <input type="number" name="width">   
<br><br>   
Length: <input type="number" name="length"> <br>   
<input type = "submit" name = "submit" value="Calculate">   
</form>   
</body>   
</html>  
<?php   
if(isset($_POST['submit']))  
    {   
$width = $_POST['width'];   
$length = $_POST['length'];   
$area = $width*$length;   
echo "The area of a rectangle with $width x $length is $area";   
}   
?>   

Output:

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now