PHP determines whether the data in FORM or URL parameters is an integer. formurl_PHP tutorial

Source: Internet
Author: User
PHP determines whether the data in FORM or URL parameters is an integer (formurl. PHP determines whether the data in FORM or URL parameters is an integer. formurlPHP determines whether the data in FORM or URL parameters is an integer, the is_int function uses PHP to determine whether the data in the FORM or URL parameter is an integer for FORM or URL parameters. 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
The code is as follows:
If (preg_match ("/^ \ d * $/", $ fgid) echo ('number ');
Else echo ('not a digit ');

Or use the function
The code is as follows:
If (is_numeric ($ fgid) echo ('number ');
Else echo ('not a digit ');

Using PHP to determine whether the data in FORM or URL parameters is an integer. the is_int function has passed the FORM or URL parameters...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.