The function is_integer() checks whether the type of a variable is integer. This function is an alias of is_int().
bool is_integer ( mixed $value )
Sr.No | Parameter & Description |
---|---|
1 |
value The variable whose type is being evaluated. |
This function returns true if value is an int, false otherwise.
PHP 4 and above
Following example demonstrates return values with different types of variables −
<?php $a = 33; echo "a is "; var_dump(is_integer($a)); echo "<br>"; $b = "33"; echo "b is "; var_dump(is_integer($b)); echo "<br>"; $c = 33.5; echo "c is "; var_dump(is_integer($c)); echo "<br>"; $d = "33.5"; echo "d is "; var_dump(is_integer($d)); echo "<br>"; $e = true; echo "e is "; var_dump(is_integer($e)); echo "<br>"; $f = false; echo "f is "; var_dump(is_integer($f)); echo "<br>"; $g = null; echo "g is "; var_dump(is_integer($g)); echo "<br>"; ?>
This will produce following result −
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)