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

ParameterIs RequiredDescription
numberRequired. Value to calculate the logarithm for
baseOptional. 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 TypeFloat

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.





















Home »
  PHP Tutorial »
    Function reference »




PHP Array Functions
PHP Calendar Functions
PHP Class Functions
PHP Data Type Functions
PHP Date Functions
PHP File Functions
PHP Image Functions
PHP Math Functions
PHP MySQLi Functions
PHP SimpleXML Functions
PHP String Functions
PHP XML Functions
PHP Zip Functions