w3resource

PHP: log() function

Description

The log() function returns the natural logarithm of a number.

Version:

(PHP 4 and above)

Syntax:

log(number,nbase)

Parameter:

Name Description Required /
Optional
Type
number The value to calculate the logarithm. Required Float
nbase The base to use. Default is 'e'. Optional Float

Return value:

The logarithm of number to nbase, if given, or the natural logarithm.

Value Type: Float.

Example :

<?php
echo(log(2) . "<br />");
echo(log(1.234) . "<br />");
echo(log(0) . "<br />");
echo(log(1) . "<br />");
?>

Output :

0.69314718056
0.210260925483
-INF
0

View the example in the browser

See also

PHP Function Reference

Previous: log1p
Next: max



Become a Patron!

Follow us on Facebook and Twitter for latest update.

It will be nice if you may share this link in any developer community or anywhere else, from where other developers may find this content. Thanks.

https://w3resource.com/php/function-reference/log.php