1. Technology
You can opt-out at any time. Please refer to our privacy policy for contact information.

The Pi () function and M_PI


Top Related Searches

The PI () Function:

The PI () function is used in many mathematical calculations and is approximately equal to 3.14159265358979323846. By default it will use a precision of 14 decimals, however this can be changed and set as high as 20 in the php.ini file. Here are some examples of it in use:
 echo pi() ;
 echo "<br>";
 echo pi () * 4;

Using M_PI:

M_PI is a constant that will produce the same value as PI (). Our previous example could be rewritten using M_PI like this:
 echo M_PI;
 echo "<br>";
 echo M_PI * 4;

Other Variations:

M_PI_2 = Half of PI ()
M_PI_4 = One Quarter PI ()
M_1_PI =One divided by PI ()
M_2_PI = Two divided by PI ()
M_SQRTPI = Square root of PI ()
M_2_SQRTPI = Two Divided by the square root of PI ()
Related Video
Using PHP With HTML
Basic PHP Syntax
  1. About.com
  2. Technology
  3. PHP / MySQL
  4. PHP Functions
  5. PHP Pi - Using Pi in PHP - PHP 3.141592 Pi

©2014 About.com. All rights reserved.