8. PHP Program to find the Volume of a Cylinder.
How does this program work?
- In this program you will learn about how to calculate Volume of a Cylinder using PHP.
- This program requires the user input to enter the radius and height of a Cylinder.
- Finally, we get the volume of a cylinder by using volume formula.
Here is the code
<html>
<head>
<title>PHP Program To find the Volume of a Cylinder</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num1" value="" placeholder="Enter the Radius of a Cylinder"/>
</td>
</tr>
<tr>
<td> <input type="text" name="num2" value="" placeholder="Enter the Height of a Cylinder"/>
</td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$r = $_POST['num1'];
$h = $_POST['num2'];
$pi = 3.14;
$volume = $pi * $r * $r * $h; //Formula for volume of a Cylinder
echo "Volume of a Cylinder is: ".$volume;
return 0;
}
?>
</body>
</html>