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.No||Parameter & Description|
a floating point number to raise e to
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
This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x.
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 −
<?php echo "exp(" . M_LN2 . ") = " . exp(M_LN2); ?>
This returns largest integer−
exp(0.69314718055995) = 2
M_LN10 is another predefined constant representing loge10. This program calculates exp(M_LN10) and returns 10 −
<?php echo "exp(" . M_LN10 . ") = " . exp(M_LN10); ?>
This returns following output−
exp(2.302585092994) = 10