PHP log10() 函数
log10() 函数是预定义的 PHP 数学函数。它用于返回一个数的以10为底的对数。
语法
log10(num);
参数 | 描述 | 必填/可选 |
---|---|---|
num | 指定要计算对数的值。 | 必填 |
注:num是一个以固定10进制为基础的输入数字。
示例1
<?php
num=5;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log($num);
?>
输出:
Your number is: 5
By using log10() function your number is : 1.6094379124341
示例2
<?php
num=1.234;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log($num);
?>
输出:
Your number is: 1.234
By using log10() function your number is : 0.2102609254832
示例3
<?php
num=1;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log($num);
?>
输出:
Your number is: 1
By using log10() function your number is : 0
示例4
<?php
num=0;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log($num);
?>
输出:
Your number is: 0
By using log10() function your number is : -INF
示例5
<?php
num=-1;
echo "Your number is: ".num;
echo "<br>"."By using log10() function your number is : ".log($num);
?>
输出:
Your number is: -1
By using log10() function your number is : NAN