PHP - is_long() 函数



定义和用法

函数 is_long() 检查变量的类型是否为整数。

语法

bool is_long ( mixed $value )

参数

序号 参数及描述
1

正在评估其类型的变量。

返回值

如果 value 是 int,则此函数返回 true,否则返回 false

依赖项

PHP 4 及更高版本

示例

以下示例演示了不同类型变量的返回值 -

<?php
   $a = 33;
   echo "a is "; var_dump(is_long($a)); echo "<br>";

   $b = "33";
   echo "b is "; var_dump(is_long($b)); echo "<br>";

   $c = 33.5;
   echo "c is "; var_dump(is_long($c)); echo "<br>";

   $d = "33.5";
   echo "d is "; var_dump(is_long($d)); echo "<br>";

   $e = true;
   echo "e is "; var_dump(is_long($e)); echo "<br>";

   $f = false;
   echo "f is "; var_dump(is_long($f)); echo "<br>";

   $g = null;
   echo "g is "; var_dump(is_long($g)); echo "<br>";
?>

输出

这将产生以下结果 -

a is bool(true)
b is bool(false)
c is bool(false)
d is bool(false)
e is bool(false)
f is bool(false)
g is bool(false)
php_variable_handling_functions.htm
广告