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