B) Write a PHP script to calculate the area and volume of a cylinder using a function.
<?php
// Function to calculate area and volume
function cylinder($radius, $height) {
$area = 2 * pi() * $radius * ($radius + $height);
$volume = pi() * $radius * $radius * $height;
return ["area" => $area, "volume" => $volume];
}
$radius = 3;
$height = 7;
$result = cylinder($radius, $height);
// Display results
echo "Radius: " . $radius . "<br>";
echo "Height: " . $height . "<br>";
echo "Surface Area of Cylinder: " . round($result['area'], 2) . "<br>";
echo "Volume of Cylinder: " . round($result['volume'], 2);
?>
