Math Log in PHP

In this article I explain the PHP math log function.
  • 1722


The PHP math functions handle values within the range of integer and float types. In this article I describe PHP math log function.

PHP log() function

The PHP math log function is used to return the natural logarithm (base E) of a number.


log( number, base)

Parameters in
 log function

It takes two parameters; they are:

Parameter Description
number It specifies a number.
base The optional logarithmic base to use (defaults to "e" and so to the natural logarithm).

Example of log function






echo "log value of <b>2</b> is <b>$val1</b> <br />";

echo "log value of <b>0</b> is <b>$val2</b> <br />";

echo "log value of <b>1.232</b> is <b>$val3</b> <br />";

echo "log value of <b>1</b> is <b>$val4</b> <br />";


Note: The code above is used to convert numbers to the natural logarithm (base E) of a number. So in the above example the numbers "2", "0", "1.232" and "1" are converted to the natural logarithm of the number.




More Articles

© 2020 DotNetHeaven. All rights reserved.