[thelist] Form validation function in PHP
David Bindel
dbindel at austin.rr.com
Sat Jun 8 20:27:00 CDT 2002
I am trying to write a PHP function that checks to see if a
specified variable has been set and is not empty so I don't
have to write a bunch of code for each variable I want to
check.
I have tried using the isset() and empty() functions to
check whether $myvar exists and is not empty this using the
following code, but apparently, PHP cannot evaluate a string
which is the name of a variable ("$myvar"):
function filled($variable) {
if (isset(eval($variable)) && !empty(eval($variable))) {
return true;
} else {return false;}
}
echo filled("\$myvar");
But it gives me this error:
Parse error: parse error, unexpected T_EVAL, expecting
T_VARIABLE or '$' in .....
Does anyone know how I can make this function work right?
TIA,
David Bindel
More information about the thelist
mailing list