Named Constants

PHP provides the following named constants. Not all constants are available in all versions of PHP, and only M_PI is available in any version of PHP 3.

Named Constant Value Description Availability
M_1_PI 0.31830988618379067154 1 / pi PHP 4 RC 1+
M_2_PI 0.63661977236758134308 2 / pi PHP 4 RC 1+
M_2_SQRTPI 1.12837916709551257390 2 / sqrt(pi) PHP 4 RC 1+
M_E 2.7182818284590452354 e; natural logarithm base PHP 4 RC 1+
M_EULER 0.57721566490153286061 Euler’s constant PHP 4.0.2+
M_LN2 0.69314718055994530942 loge2 PHP 4 RC 1+
M_LN10 2.30258509299404568402 loge10 PHP 4 RC 1+
M_LNPI 1.14472988584940017414 logepi PHP 4.0.2+
M_LOG2E 1.4426950408889634074 log2e PHP 4 RC 1+
M_LOG10E 0.43429448190325182765 log10e PHP 4 RC 1+
M_PI 3.14159265358979323846 ...

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.