Get the mathematical value of pi with this function, or through the use of the constant M_PI. Pi is the ratio of a circle’s circumference to its diameter.

As pi is an irrational number (the most famous of them all) the return value is only an approximation but suitable for most calculations. The decimal precision is based on the setting in your ini file for floats (default of 14).

$radius = 17;
$area   = ($radius ^ 2) * pi(); // 59.6902604182
$circ   = 2 * $radius * pi();   // 106.814150222

Happy Pi Day

March 14th - since it can be written as 3-14 - has been declared “Pi Day”. This, of course, means nothing. :)

It’s simply a chance for math enthusiasts to celebrate a day… and eat some pie.

So if you’re going to celebrate Pi Day, here’s a tip. Since most, or all, pies are round, make a square one. Then you can point to it and say…

.

(wait for it)

.

… that pi r squared. **rim shot**