PHP pi()
Published Jul 4, 2023Updated Jul 15, 2023
Contribute to Docs
The pi() function returns the value of PI (π).
Syntax
pi();
The pi() function has no parameters. It returns the value of π as a float. M_PI, being a constant, also returns the same value.
Codebyte Example
Using pi() to return the value of π:
Related Constants
Some other predefined named constants related to π are:
| Constant | Value |
|---|---|
M_PI_2 |
π/2 or 1.570796 |
M_PI_4 |
π/4 or 0.785398 |
M_1_PI |
1/π or 0.318309 |
M_2_PI |
2/π or 0.636619 |
M_SQRTPI |
sqrt(π) or 1.772453 |
M_2_SQRTPI |
2/sqrt(π) or 1.128379 |
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn PHP on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours