<?Php
echo LOG10(5);// Output is 0.69897000433602
echo "<br>";
echo LOG10(-6);// Output is NAN
echo "<br>";
echo LOG10(0);// Output is -INF
echo "<br>";
echo LOG10(8.6);// Output is 0.93449845124357
?>
Syntax
LOG10(X);
X is the input number with Base fixed base 10. We get output as LOG of X
<?php
$intensity = 0.001; // Sound intensity in watts per square meter
$reference = 0.00001; // Reference intensity
$decibels = 10 * log10($intensity / $reference);
echo "Sound intensity: $decibels dB";
?>
<?php
$percentage = 75;
$log_percentage = log10($percentage / 100);
echo "Logarithm base 10 of 75%: $log_percentage";
?>
Output
Logarithm base 10 of 75%: -0.1249387366083
The log10() function computes the logarithm of a number with base 10. Here's a simple example:
<?php
echo log10(1000); // Logarithm base 10 of 1000
echo "<br>";
echo log10(10); // Logarithm base 10 of 10
?>
Base-10 logarithms are commonly used in scientific and engineering fields to represent large-scale measurements such as pH or decibels:
<?php
$intensity = 1000000; // Sound intensity
$decibels = 10 * log10($intensity);
echo "Decibels: " . $decibels;
?>
Handle invalid input (e.g., negative numbers) when using log10():
<?php
$num = -10;
if ($num > 0) {
echo log10($num);
} else {
echo "Logarithm not defined for non-positive numbers.";
}
?>