PHP log()Functions

PHP Math 参考手册PHP Math Reference Manual

Examples

Returns 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 withbaseas the basenumberthe logarithm of.


Syntax

log(number,base);

Parameters Description
number Required. Specifies the value for which to calculate the logarithm.
base Optional. The base of the logarithm to use. Default is 'e'.

Technical Details

Return value: The natural logarithm of a number, or withbaseas the basenumberthe logarithm of.
Return type: Float
PHP Version: 4+
PHP Changelog: PHP 4.3: Added the base parameter.


PHP Math 参考手册PHP Math Reference Manual Other Extensions