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);
?>
Try it Yourself »

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 Values

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
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.