PHP - pi() Function
The PHP pi() function is used to return the value of PI.
Syntax
pi()
Parameters
No parameter is required.
Return Value
Returns the value of PI, i.e., 3.1415926535898
Example:
In the below example, pi() function is used to calculate the area of a circle.
<?php $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