pi

float pi(void) 

Returns the value of pi.

Returns:

Value of pi

Description:

Returns a double containing the value of pi. The number of decimal places is system-specific; for instance, on a Linux x86 box the value returned is 3.1415926535898.

Note that it will be slightly faster in most cases to simply use the named constant M_PI, which is provided by PHP. The pi() function simply returns this value.

Version:

PHP 3, PHP 4

Example:

Get pi
$radius = 6; 
$area = pi() * pow($radius, 2); // area = pi * r^2 
echo "Area of circle with radius $radius is $area"; 

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.