THE WORLD'S LARGEST WEB DEVELOPER SITE

PHP log() Function

❮ PHP Math Reference

Example

Return the natural logarithm of different numbers:

<?php
echo(log(2.7183) . "<br>");
echo(log(2) . "<br>");
echo(log(1) . "<br>");
echo(log(0);
?>
Run example »

Definition and Usage

The log() function returns the natural logarithm of a number, or the logarithm of number to base.


Syntax

log(number,base);

Parameter Description
number Required. Specifies the value to calculate the logarithm for
base Optional. The logarithmic base to use. Default is 'e'

Technical Details

Return Value: The natural logarithm of a number, or the logarithm of number to base
Return Type: Float
PHP Version: 4+
PHP Changelog: PHP 4.3: The base parameter were added

❮ PHP Math Reference