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