PHP log() Function
In this chapter you will learn:
- Definition for PHP log() Function
- Syntax for PHP log() Function
- Parameter for PHP log() Function
- Return for PHP log() Function
- Example - Return the natural logarithm of different numbers
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/* java2 s . c om*/
echo log(2.7183) . "\n";
echo log(2) . "\n";
echo log(1) . "\n";
echo log(0);
?>
The code above generates the following result.
Next chapter...
What you will learn in the next chapter:
- Definition for PHP log10() Function
- Syntax for PHP log10() Function
- Parameter for PHP log10() Function
- Return for PHP log10() Function
- Example - Return the base-10 logarithm of different numbers
Home » PHP Tutorial » PHP Math Functions