Integer Data Type:
An integer is whole number value. In simple words it is a number with no fractional component. In PHP integer is the same as in other programming language having number value range between:
-2,147,483,648 and +2,147,483,647.
In PHP you can also declare variable without mentioning their data type. As PHP is loosely bounded language and will try to determine type of variable based on the value hold by variable.
Declaration of variable without its type:
$variable =41;
$Value_Int=45;
$Value_Int2=-78;
Here the variable hold the whole number value so it is of integer type.
Check variable using is_integer() function in PHP:
To check whether the variable is integer data type or not php supports built in functions name as is_integer() function. This function takes integer value as a parameter and returns a 1 if true and nothing if the variable is not integer type value.
Code:
<?php
$a = 0.89;
$b = -341;
$c = 0.006;
$d = 122;
echo( is_integer($a) );
echo "</br>";
echo( is_integer($b) );
echo "</br>";
echo( is_integer($c) );
echo "</br>";
echo( is_integer($d) );
?>
This is simple code to check variable is integer data type or not using is_integer() function.
This simple article tells that how we can check variable is integer data type or not using is_integer() function in PHP.