is_integer
is_int alias
is_integer()
function checks whether the variable is an integer type.
This function is an alias for is_int()
.
Check whether the variable is an integer type:
<?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>" ; ?>
Try it yourself
In PHP, neither the boolean value true
nor the string "32"
is an integer type, even if the string contains numbers. So, checks for $d
and $e
will return FALSE
. Similarly, $f
is a string, and although its content is "null"
, it is not an integer type either, so the check will return FALSE
. Floating point numbers such as $c
are obviously not integers, so is_int($c)
will also return FALSE
.
is_integer ( variable ) ;
parameter | describe |
---|---|
variable | Required. Specifies the variable to check. |