PHP exp() Function

PHPServer Side ProgrammingProgramming

Definition and Usage

The exp() function calculates exponent of e that is Euler Number. PHP has a predefined constant M_E that represents Euler Number and is equal to 2.7182818284590452354. Hence, exp(x) returns 2.7182818284590452354x

This function always returns a float.


exp ( float $arg ) : float


Sr.NoParameter & Description
a floating point number to raise e to

Return Values

PHP exp() function returns the Euler Number e raised to given arg. Note that e is base of natural algorithm. The exp() function is inverse of natural logarithm.

Hence, if logex = y, then ey=x

PHP Version

This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.


 Live Demo

One of the predefined constants in PHP is M_LN2 which stands for loge2 and is equal to 0.69314718055994530942. So exp() of this value will return 2 −

   echo "exp(" . M_LN2 . ") = " . exp(M_LN2);


This returns largest integer−

exp(0.69314718055995) = 2


 Live Demo

M_LN10 is another predefined constant representing loge10. This program calculates exp(M_LN10) and returns 10 −

   echo "exp(" . M_LN10 . ") = " . exp(M_LN10);


This returns following output−

exp(2.302585092994) = 10
Published on 29-Jun-2020 12:17:31