PHP determines whether the form or URL parameter data is an integer, and the Is_int function does not have the means to determine whether it is an integer because the form comes over a string of data from the form or URL parameter.
Is_numeric can be used to determine whether a number type, and then judge whether there is a decimal point can be judged is not an integer
if (!is_numeric ($page) | | Strpos ($page, ".")! ==false) {
echo "is not an integer";
} Else{
echo "is an integer";
}
Sometimes we need to determine whether the ID is a number method:
The method of judging number in Dedecms
$cid = Empty ($cid)? 1:intval (Preg_replace ("/[^-\d]+[^\d]/", "", $cid));
We recommend that you filter the key parameters. such as the number of regular filter
Copy Code code as follows:
if (Preg_match ("/^\d*$/", $fgid)) echo (' is a number ');
else echo (' not number ');
or use a function
Copy Code code as follows:
if (Is_numeric ($fgid)) echo (' is a number ');
else echo (' not number ');