- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
PHP exp() Function
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.
Syntax
exp ( float $arg ) : float
Parameters
Sr.No | Parameter & Description |
---|---|
1 | arg 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.
Example
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); ?>
Output
This returns largest integer−
exp(0.69314718055995) = 2
Example
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); ?>
Output
This returns following output−
exp(2.302585092994) = 10