note 29198 deleted from function.empty by philip
| From: | philip@php.net | Date: | Wed, 26 Mar 2003 01:04:12 +0000 |
| Subject: | note 29198 deleted from function.empty by philip | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-45827@lists.php.net to get a copy of this message | ||
in regards to empty() and isset().. it seems that they will ALWAYS return true with "" in
an array element:
if(empty($array[element])){
echo "it is empty";
}else{
echo "not empty";
}
it shows that when that array element is pulled from an empty sql table (mysql) using a blank
(empty) form input field the "is empty" string will NEVER be ran because either
"" "0" or "none" and null are all considered to be a value of some
kind. also i find that isset() is not a very good choice to check unused form fields because when
the variable is passed from the form to the script it has "something" in it. what that
something is we might never know..:
<input type="text" name="foo" value="array[element]">
now if in the form you just press submit without typing anything in the box then empty and isset
consideres that array[element] as being full of something and isset consideres it as set since it
tried to get a blank field from an sql record..
i havent quite figured out what system will work for testing "empty" variables .. i
believe they are either !isset or they have something in them if isset=true..