Three php form validation functions commonly used in project development

Source: Internet
Author: User
PHP Web development commonly used in three form validation functions, these are some of the frequently used judgment function.

ISSET ();--suitable for detecting the presence of this parameter.
Definition and scope: used to test whether a variable has a value (including 0,false, or an empty string, but not null), that is: "...?" Fo= "can also be detected and therefore not applicable. However, if the URL parameter does not contain the FO parameter, it can be detected with isset, at which point Isset ($_get[' fo ') returns false.
Not applicable: This function is not suitable for validating the text in an HTML form in an efficient way. To check whether the user input text is valid, you can use empty ();
Empty ();--The best use of a function.
Definition and scope: used to check if a variable has a null value: include: empty string, 0,null or FALSE, i.e.: "...?" Fo= "or" ...? Fo=0 ", empty detected results are ture, not applicable range: not used to detect the parameters can be 0.
Is_numeric ();--only for the detection of numbers, but if the parameter name does not exist, it will be wrong, so it is not suitable for the first layer detection.
Comprehensive Example:

<?php ini_set ("Display_errors", 1);//ini_set ("error_reporting", E_ALL); Print_r error_reporting (E_all); $a =null; if (Isset ($a)) echo ' variable $ A ' isset is true '; Echo ' 
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 

Related articles:

PHP Verification of ID number correctness function

PHP ID Number Verification function

Get real IP address and IP address verification functions in PHP

  • 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.