is_double()函數是PHP中的內置函數,用於查找給定值是否為double。
用法:
bool is_double( $variable_name )
參數:該函數接受上麵提到並在下麵描述的一個參數:
- $variable_name:該參數保存需要檢查的值。
返回值:它是一個布爾值,即如果$variable_name包含的是雙精度值,則為TRUE,否則返回FALSE。
以下示例程序旨在說明PHP中的is_double()函數:
程序1:
<?php
// PHP code to implement is_double()
// function
function square($num)
{
return (is_double($num));
}
echo square(9.09) ."\n"; // outputs '1'.
echo square(FALSE) ."\n"; // gives no output.
echo square(14) ."\n"; // gives no output.
echo square(56.30) ."\n"; // outputs '1'
?>
輸出:
1 1
程序2:
<?php
// PHP code to implement is_double()
// function
$variable_name1 = 67.099;
$variable_name2 = 32;
$variable_name3 = "abc";
$variable_name4 = FALSE;
// $variable_name1 is double value, gives TRUE
if (is_double($variable_name1))
echo "$variable_name1 is a double value. \n";
else
echo "$variable_name1 is not a double value. \n";
// $variable_name2 is not a double value, gives FALSE
if (is_double($variable_name2))
echo "$variable_name2 is a double value. \n";
else
echo "$variable_name2 is not a double value. \n";
// $variable_name3 is not a double value, gives FALSE
if (is_double($variable_name3))
echo "$variable_name3 is a double value. \n";
else
echo "$variable_name3 is not a double value. \n";
// $variable_name4 is not a double value, gives FALSE
if (is_double($variable_name4))
echo "FALSE is a double value. \n";
else
echo "FALSE is not a double value. \n";
?>
輸出:
67.099 is a double value. 32 is not a double value. abc is not a double value. FALSE is not a double value.
參考: https://www.php.net/manual/en/function.is-double.php
相關用法
- d3.js d3.map.set()用法及代碼示例
- PHP ord()用法及代碼示例
- d3.js d3.hsl()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js pan()用法及代碼示例
- p5.js max()用法及代碼示例
- d3.js d3.min()用法及代碼示例
- p5.js tan()用法及代碼示例
- PHP Ds\Map map()用法及代碼示例
- p5.js hue()用法及代碼示例
- p5.js min()用法及代碼示例
注:本文由純淨天空篩選整理自AshokJaiswal大神的英文原創作品 PHP | is_double() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。