PHP is_float() 函数
实例
检查变量是否为浮点类型:
<?php
$a = 32;
echo "a is " . is_float($a) . "<br>";
$b = 0;
echo "b is " . is_float($b) . "<br>";
$c = 32.5;
echo "c is " . is_float($c) . "<br>";
$d = "32";
echo "d is " . is_float($d) . "<br>";
$e = true;
echo "e is " . is_float($e) . "<br>";
$f = "null";
echo "f is " . is_float($f) . "<br>";
$g = 1.e3;
echo "g is " . is_float($g) . "<br>";
?>
亲自试一试 »
$a = 32;
echo "a is " . is_float($a) . "<br>";
$b = 0;
echo "b is " . is_float($b) . "<br>";
$c = 32.5;
echo "c is " . is_float($c) . "<br>";
$d = "32";
echo "d is " . is_float($d) . "<br>";
$e = true;
echo "e is " . is_float($e) . "<br>";
$f = "null";
echo "f is " . is_float($f) . "<br>";
$g = 1.e3;
echo "g is " . is_float($g) . "<br>";
?>
定义和用法
is_float() 函数检查变量是否为浮点类型。
如果变量是float类型,这个函数返回true (1),否则返回false。
语法
is_float(variable);
参数值
参数 | 描述 |
---|---|
variable | 必需。指定要检查的变量 |
技术细节
返回值: | 如果 变量 是浮点数,则为 TRUE,否则为 FALSE |
---|---|
返回类型: | Boolean |
PHP 版本: | 4.0+ |