note 18325 deleted from function.empty by sniper

From: Date: Sat, 23 Aug 2003 00:21:03 +0000
Subject: note 18325 deleted from function.empty by sniper
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-54916@lists.php.net to get a copy of this message
Note Submitter: cezeugoh@hotmail.com ---- It would appear empty() has to be used in conjunction with isset(). painful experience has taught me that empty() alone doesnt work as expected with empty strings i.e "". empty() would return false where the variable is existent and is empty or where the variable is non-existent also. so you might have to test first with isset() to find out if the variable is existent then check with empty() to see if it contains an empty string. An example is as follows: if (!isset($a)) { //echo the variable doesnt exist! } elseif empty($a) { // echo it exists but is empty! } else { //echo it exists but and contains something! }

« previous php.notes (#54916) next »