Adam Williams said the following on 11/12/2003 11:37 AM>>
Hello,

I need to test a variable to see if it contains a value or not, and if not, do something. My php is a little rusty, so which would be better?

if ( !$var )
{ echo "do something";}

or

if ( !isset($var )
{ echo "do something";}

or are both of those wrong, and if so, how hsoudl I check if a variable is false, null, doesn't contain a value, etc...

What I am doing is checking a field in an sql table, and if the field is null, empty, etc... then do something. so what is the best way to check the field if its null, empty, etc...?

if (!isset($var) or empty($var) ) {
        echo "do something....";
}

HTH
R'twick

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to