PHP Varibale Data Type Check Function
PHP predefine some functions to Check data type:
- is_int( ):Check the given value and see whether it is integer or not
- is_integer( ): Alias of is_int()
- is_float( ):Check the given value and see whether it is float or not
- is_double( ):Alias of is_float()
- is_numeric( ):Check the given value and see whether it is either integer or float
- is_string( ):Check the given value and see whether it is string or not
- is_bool( ):Check the given value and see whether it is Boolean or not
- is_array( ):Check the given value and see whether it is array or not
- is_object( ):Check the given value and see whether it is object or not
- is_null( ):Check the given value and see whether it is null or not
- is_resource( ):Finds whether a variable is a resource
<?php
$x = "123";
$y = array(1,2,3);
if(is_numeric($x) && is_array($y)){
echo "x is either a integer or float<br>";
echo "y is a array";
}
?>