1. Home
  2. Computing & Technology
  3. PHP / MySQL

PHP Log () Function

By Angela Bradley, About.com

Definition: The Log () PHP Function is used to find logarithm. You can find either natural logarithm (using the base of e - which is approximately 2.71) or a logarithm of a specified base. If you specify a base you are really just doing logb(n) = log(n)/log(b). It is written as log(argument, base) so if you wanted to find the log2(8) you would write it as log(8,2).
Also Known As: Logarithm
Examples:
<?php
echo(log(8,2) . "<br />");
echo(log(8) . "<br />");
echo(log(2) . "<br />");
echo(log(8)/log(2) . "<br />");
?>
This would return the results:
3
2.0794415416798
0.69314718055995
3
Explore PHP / MySQL
About.com Special Features

Stay connected and entertained with reviews on tips on the latest HDTVs, cellphones and more. More >

Easy ways to connect two computers for networking purposes. More >

  1. Home
  2. Computing & Technology
  3. PHP / MySQL
  4. PHP Functions
  5. Log PHP Function - Logarithm Function PHP

©2009 About.com, a part of The New York Times Company.

All rights reserved.