當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


PHP log10()用法及代碼示例


log10() 函數是預定義的 php 數學函數。它用於返回一個數字的以 10 為底的對數。

用法:

log10(num);
參數 描述 必需/可選
Number 指定計算對數的值。 Required

注:num 為輸入數字,Base 固定為 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






相關用法


注:本文由純淨天空篩選整理自 PHP log10() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。