PHP determines whether the data in FORM or URL parameters is an integer. formurl
PHP checks whether the data from FORM or URL parameters is an integer. The is_int function cannot determine whether the data from FORM or URL parameters is an integer because FORM is a string.
Is_numeric can be used to determine whether it is of the numeric type, and then determine whether there is a decimal point to determine whether it is an integer.
If (! Is_numeric ($ page) | strpos ($ page ,".")! = False) {echo "not an integer";} else {echo "is an integer ";}
Sometimes we need to determine whether the id is a number:
Method for Determining numbers in dedecms
$ Cid = empty ($ cid )? 1: intval (preg_replace ("/[^-\ d] + [^ \ d]/", '', $ cid ));
We recommend that you filter key parameters. Such as digital Regular Expression Filtering
Copy codeThe Code is as follows:
If (preg_match ("/^ \ d * $/", $ fgid) echo ('Number ');
Else echo ('not a digit ');
Or use the Function
Copy codeThe Code is as follows:
If (is_numeric ($ fgid) echo ('Number ');
Else echo ('not a digit ');