Write a PHP program to calculate area of rectangle
Description:
Write a PHP program to calculate area of rectangle by using PHP Function.
Condition
- You must use a PHP Function.
- There should be two arguments i.e. length & width.
View Solution/Program.
<?php
function rect_area($length = 2, $width = 4) //function has declared
{
$area = $length * $width;
echo "Area Of Rectangle with length " . $length . " & width " . $width . " is " . $area ;
}
rect_area(); // function has been called.
?>
Tutorials Class - Output Window
Area Of Rectangle with length 2 & width 4 is 8 .
Learn more about the similar topics:
Tutorials |
---|
PHP Functions |
Exercises & Assignments |
---|
Factorial program in PHP using recursive function |
Write a PHP program to check if a person is eligible to vote |
Write a PHP program to calculate area of rectangle |
Interview Questions & Answers |
---|
What is PHP Function? |
What is PHP floor() function? |