ISSET();——Suitable for detecting whether this parameter exists.
Definition and scope: used to test whether a variable has a value (including 0, FALSE, or an empty string, but not NULL), that is: "http://localhost/?fo=" can also pass the test, Therefore not applicable. But if the "http://localhost/" parameter does not contain the fo parameter, you can use isset to detect it. In this case, isset($_GET['fo']) returns false.
Not applicable: This function is not suitable for validating text in html forms in an efficient way. To check whether the user input text is valid, you can use empty();
empty(); - the best function to use.
Definition and scope: Used to check whether a variable has a null value: including: empty string, 0, null or false, that is: "http://localhost/?fo=" or "http://localhost/?fo =0", the results detected by empty are all true, not applicable scope: not suitable for detecting parameters that can be 0.
is_numeric(); - only suitable for detecting numbers, but if the parameter name does not exist, an error will occur, so it is not suitable for the first level of detection.
Comprehensive example:
Copy the code The code is as follows:
ini_set("display_errors",1);
//ini_set("error_reporting",E_ALL); print_r
error_reporting(E_ALL) ;
$a=NULL;
if(isset($a))echo 'isset of variable $a is true';
echo '
Pass valid value Pass Empty value Pass 0 value
Gender: Male Gender: Female
< a href="/">Clear
The above introduces the difference between NUMERIC and DECIMAL and how to use the three functions ISSET, empty, and is_numeric of PHP form validation, including the difference between NUMERIC and DECIMAL. I hope it will be helpful to friends who are interested in PHP tutorials.