7. PHP Program to find Area of a Sphere.
How does this program work?
- In this program you will learn about how to find Area of a Sphere using PHP.
- This program requires the user input to enter the radius of a Sphere.
- By using Area of Sphere formula we can get the Output.
Here is the code
<html>
<head>
<title>PHP Program To find Area of a Sphere</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num" value="" placeholder="Enter the Radius of a Sphere"/>
</td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/>
</td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$r = $_POST['num'];
$pi = 3.14;
$area = 4 * $pi * $r * $r; //Formula for Area of Sphere
echo "Area of a sphere is: ".$area;
return 0;
}
?>
</body>
</html>