Area is the size of the surface of an object. In this article, we will discuss about the formula and php code in solving for the area of a circle.
Formula
a = to the length of the side
r = radius of a circle
pi = 3.1415926535898
PHP Code
<?phpI used the pi() function but you can also declare a variable with the value of 3.1415926535898. The pow() function is used to express exponential values. Let's say pow($radius,2) means the value of $radius will be raised to 2 with the value of 10 for the $radius.
$radius = 10;
$area = pi()*pow($radius,2);
echo "The area of the square with the side of $radius is $area";
?>
Output
Circumference of a Circle Formula
Circumference = 2 × π × r
PHP Code
<?php
$radius = 10;
$circumference = 2 * pi()*$radius;
echo "The circumference of the circle with the radius of $radius is $circumference";
?>
0 comments:
Post a Comment