# PHP log10() Function

PHPServer Side ProgrammingProgramming

## Definition and Usage

The log10 () function calculates base-10 logarithm of a number.

Base-10 logarithm is also called common or sandard algorithm. The log10(x) function calculates log10x. It is related to natural algorithm by following equation −

log10x=logex/loge10 So that

log10100=loge100/loge10 = 2

In PHP, log10 is represented by log10() function

log10 ( float $arg ) : float ## Parameters Sr.NoParameter & Description 1arg The number whose base-10 logarithm is to be calculated ## Return Values PHP log10() function returns base-10 logarithm of arg. ## PHP Version This function is available in PHP versions 4.x, PHP 5.x as well as PHP 7.x. ## Example Live Demo Following example calculates base-10 logarithm of 100 <?php$arg=100;
echo "log10(" . $arg. ")=" . log10($arg) . "\n";
?>

## Output

This will produce following result −

log10(100)=2

## Example

Live Demo

Following code calculates base-10 logarithm of Euler Number M_E. The result is equal to a predefined constant M_LOG10E

<?php
$arg=M_E; echo "log10(" .$arg. ")=" . log10($arg) . "\n"; echo "predefined constant M_LOG10E=" . M_LOG10E; ?> ## Output This will produce following result − log10(2.718281828459)=0.43429448190325 predefined constant M_LOG10E=0.43429448190325 ## Example Live Demo Following example calculates log100 and returns -infinity. − <?php$arg=0;
echo "log10(" . $arg. ")=" . log10($arg) . "\n";
?>

## Output

This will produce following result −

log10(0)=-INF

## Example

Live Demo

Similarly sqrt(-1) results in NAN. Hence its log10() also returns NAN −

<?php
$arg=sqrt(-1); echo "log10(" .$arg. ")=" . log10(\$arg) . "\n";
?>

## Output

This will produce following result −

log10(NAN)=NAN