is_numeric() when validating form data, which will always be strings.
is_int() will check if the variable type is integer. so form data will always be false.
is_numeric() will check if the variable contain all numbers, use this function to validate form data.
<?php
$num1 = 48;
$num2 = '48';
$num3 = 'hello';
if(is_int($num1))
{
echo 'This is integer';
}
else
{
echo 'Not integer';
}
//check for above other $num2 and $num3 variables.
/*
USE is_numeric() IF YOU ARE VALIDATING FORM DATA
INSTEAD OF is_int()
*/
?>
No comments:
Post a Comment