PHP includes the standard exponential and logarithmic functions, in both base 10
and base e
varieties. Unlike with exp()
and the base e
, there is no single-argument function to raise 10
to a given power, but in its place you can use the two-argument function pow()
with 10
as the first argument.
Function | Behavior |
---|---|
pow() |
Takes two numerical arguments and returns the first argument raised to the power of the second. The value of pow($x, $y) is xy . |
exp() |
Takes a single argument and raises e to that power. The value of exp($x) is ex . |
log() |
The “natural log” function. Takes a single argument and returns its base e logarithm. If ey = x , then the value of log($x) is y . |
log10() |
Takes a single argument and returns its base-10 logarithm. If 10y = x , then the value of log10($x) is y . |