PHP exp() Function
The PHP exp() function returns e raised to the power of specified number (ex). Please note that e is the base of the natural system of logarithms, and its value is approximately 2.718282. In special cases it returns the following:
- If the argument is NAN, the result is NAN.
- If the argument is positive infinity, then the result is positive infinity.
- If the argument is negative infinity, then the result is positive zero.
Syntax
exp(x)
Parameters
number |
Required. Specify the exponent of e. |
Return Value
Returns e raised to the power of specified number.
Example:
In the example below, exp() function is used to calculate e raised to the power of specified number.
<?php echo "exp(-2) = ".exp(-2)."\n"; echo "exp(-1) = ".exp(-1)."\n"; echo "exp(0) = ".exp(0)."\n"; echo "exp(1) = ".exp(1)."\n"; echo "exp(2) = ".exp(2)."\n"; echo "exp(INF) = ".exp(INF)."\n"; echo "exp(-INF) = ".exp(-INF)."\n"; echo "exp(NAN) = ".exp(NAN)."\n"; ?>
The output of the above code will be:
exp(-2) = 0.13533528323661 exp(-1) = 0.36787944117144 exp(0) = 1 exp(1) = 2.718281828459 exp(2) = 7.3890560989307 exp(INF) = INF exp(-INF) = 0 exp(NAN) = NAN
❮ PHP Math Reference