<?Php
echo LOG(2);// Output is 0.69314718055995
echo "<br>";
echo LOG(-1);// Output is NAN
echo "<br>";
echo LOG(0);// Output is -INF
echo "<br>";
echo LOG(5.7);// Output is 1.7404661748405
?>
Syntax
LOG(X,Y);
X is the input number with Base Y (optional) . We get output as LOG of X
<?Php
echo LOG(5,2);// Output is 2.3219280948874
echo "<br>";
echo LOG(5,10);// Output is 0.69897000433602
echo "<br>";
echo LOG(5,2.7183);// Output is 1.609427153552
?>
$value = 100;
$base = 2;
$log_base2 = log($value, $base); // Output: 6.643856
echo $log_base2;
$value = -10;
$result = log($value);
if (is_nan($result)) {
echo "Logarithm undefined for negative values.";
}
Output
Logarithm undefined for negative values.
log() function in PHP?log() function used to calculate the natural logarithm of a number?log() function in PHP?e (natural logarithm) when using the log() function?log() function?log() function produce an error if the input value is negative or zero?log() function when it is successful?log() function returns false?log() function be used to calculate the logarithm of complex numbers?Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.