w3resource

PHP: exp() function

Description

The exp() function is used to calculate the  exponent of e. 'e' is the base of the natural system of logarithms (approximately 2.718282).

Version:

(PHP 4 and above)

Syntax:

exp(x)

Parameter:

Name Description Required /
Optional
Type
x Specifies the exponent. Required Float

Return value:

'e' raised to the power of x.

Value Type: Float.

Pictorial Presentation

php math exp() function

Example:


<?php
$val1= 0;
$val2=1;
$val3=2.5;
$val4=10;
$zexp1=exp($val1);
$zexp2=exp($val2);
$zexp3=exp($val3);
$zexp4=exp($val4);
echo "exp of $val1 is $zexp1<br />";
echo "exp of $val2 is $zexp2<br />";
echo "exp of $val3 is $zexp3<br />";
echo "exp of $val4 is $zexp4<br />";
?> 

Output:

exp of 0 is 1
exp of 1 is 2.71828182846
exp of 2.5 is 12.1824939607
exp of 10 is 22026.4657948

View the example in the browser

See also

PHP Function Reference

Previous: deg2rad
Next: expm1



Follow us on Facebook and Twitter for latest update.