testing a variable

From: Date: Wed, 12 Nov 2003 16:37:45 +0000
Subject: testing a variable
Groups: php.general 
Request: Send a blank email to php-general+get-169296@lists.php.net to get a copy of this message
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...?

« previous php.general (#169296) next »