find the surface area of a rectangular prism in php

To find the surface area of a rectangular prism in PHP, you can use the following formula:

main.php
Surface Area of Rectangular Prism = 2*(length*width + width*height + height*length)
84 chars
2 lines

Here is a PHP function that takes in the length, width, and height of a rectangular prism and returns its surface area:

main.php
function surfaceAreaRectangularPrism($length, $width, $height) {
    $surfaceArea = 2 * ($length * $width + $width * $height + $height * $length); 
    return $surfaceArea;
}
175 chars
5 lines

You can now use this function by passing in the length, width, and height values as arguments and store the returned surface area in a variable.

main.php
// Example usage
$length = 5;
$width = 3;
$height = 2;

$surfaceArea = surfaceAreaRectangularPrism($length, $width, $height);
echo "Surface area of rectangular prism with length $length, width $width, and height $height is $surfaceArea.";
239 chars
8 lines

Output:

main.php
Surface area of rectangular prism with length 5, width 3, and height 2 is 62.
78 chars
2 lines

gistlibby LogSnag