The log()
function returns the natural logarithm of a number,
or the logarithm of number to base.
PHP log() Function has the following syntax.
log(number,base);
Parameter | Is Required | Description |
---|---|---|
number | Required. | Value to calculate the logarithm for |
base | Optional. | The logarithmic base to use. Default is 'e' |
Item | Description |
---|---|
Return Value | The natural logarithm of a number, or the logarithm of number to base |
Return Type | Float |
Return the natural logarithm of different numbers:
<?php
echo log(2.7183) . "\n";
echo log(2) . "\n";
echo log(1) . "\n";
echo log(0);
?>
The code above generates the following result.