Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

php
math
log10
communitycreator

What is log10() in PHP?

Harris Amjad

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The log10() function in PHP uses base 10 to calculate the logarithm of a number.

Figure 1, below, shows the mathematical representation of the log10() function and the corresponding representation in PHP.

Figure 1: Mathematical representation of the log10() function and the corresponding representation in PHP

Syntax


float log10(number)

Parameter

This function requires a number whose logarithm base 10 must be calculated and greater than zero.

  • If the number is zero, then this function outputs -Inf.

  • If the number is negative, this function outputs NaN.

Return value

log10() uses base 10 to return the logarithm of a number.

Code

<?php
echo("log10(10): ");
echo (log10(10));
echo("\n");
echo("log10(2): ");
echo (log10(2));
?>
<?php
#error outputs
echo("log10(0): ");
echo (log10(0));
echo("\n");
echo("log10(-1): ");
echo (log10(-1));
?>

RELATED TAGS

php
math
log10
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring