Facebook Page Twitter Page LinkedIn Page
× PHP Tutorial PHP Advanced PHP Resources

The PHP Math pi() function returns the value of PI.




No parameter is required.

Return Value

Returns the value of PI, i.e., 3.1415926535898


In the below example, pi() function is used to calculate the area of a circle.

$x = 5; 
$area = pi()*$x*$x;

echo "Value of the PI is: ".pi()."\n";
echo "Area of the circle with radius $x is: ".$area."\n";

The output of the above code will be:

Value of the PI is: 3.1415926535898
Area of the circle with radius 5 is: 78.539816339745

❮ PHP Math Functions