log()
Published Jun 17, 2023
Contribute to Docs
The log()
function returns the natural logarithm of a value.
Syntax
$result = log(number,base);
Where number
is the number whose logarithm is to be calculated and base
is an optional parameter which signifies the logarithmic base to be used. By default base
is e.
The value returned by the function is a float
type.
Example
A basic implementation of the log()
function:
<?phpecho(log(1));?>
This will result in the following output:
0
Codebyte Example
Using log()
to return the value of 5 base 10:
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.