6. PHP Program to find Area and Circumference of a Circle.
How does this program work?
- In this program you will learn about how to calculate Area and Circumference of a Circle using PHP.
- This program requires the user input to enter the radius of a circle.
- Area and Circumference of a circle can simply be evaluated using following formula and display the output.
Here is the code
<html>
<head>
<title>PHP Program To find Area and Circumference of a Circle</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td><input type="text" name="num1" value="" placeholder="Enter the radius of a circle"/></td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/></td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$r = $_POST['num1'];
$pi = 3.14;
$area = $pi * $r * $r;
echo "Area of a Circle is: ".$area;
$cir = 2*$pi*$r;
echo "Circumference of a circle is: " .$cir;
return 0;
}
?>
</body>
</html>