Professional Documents
Culture Documents
Validation Functions
Validation Functions
empty() – checks to see if a fiven variable has a value other than null or an empty string, if returns true if
the variable doesn’t have value(or has a value of null or any empty string) and false otherwise.
Ex.
$v1=0;
$v2=’Prior’;
empty($v1); //true
empty($v1); //true
empty($v2); //false
*NOTE: this functions is perfect for making sure that the text boxes in the forms been filled out
isset() – almost opposite of empty(), returns TRUE if a variable, has a value(including null or an empty
string) or false otherwise.
Ex.
$v1=0;
$v2=’Prior’;
empty($v1); // false
empty($v1); //true
empty($v2); // true
is_numberic() – returns true if submitted variable has a valid numerical value and false otherwise.
Integers, decimals, and even strings(if they’re a valid number) can all pass the is_numeric() test.
Example:
is_numeric(2309); //true
is_numeric(’20.23’); //true
is_numeric(‘Cubs’); //false