PHP Find Area of a Circle Using Constant

PHP Find Area of a Circle Using Constant

In this tutorial I am going to show , how to find area of a circle using PHP , In this tutorial we learn how to use PHP Constant.

Formula for Calculation Area of circle :

A=πr² , where A=area, π(Pie)=3.14 and r=radius

Script / Code to to calculate area of a circle


<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>PHP Find Area of a Circle Using Constant</title>
</head>
<body>

<?php
if(isset($_POST['submit'])){
//area = pie * radius * radius
define('PI','3.14');
$radius=$_POST['radius'];
$area= PI * $radius * $radius;

echo "Area of the Circle is ".$area;
}
?>
<h2>Area of a Triangle</h2>
<form action="" method="post">
<b>Enter Radius</b><br/>
<input type="text" name="radius" ><br/>
<input type="submit" name="submit" value="Submit">
</form>

</body>
</html>

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Do you have any Query / Suggestion