Hello,
What are the output of these statements:
$var = 0
echo ( $var != "")
I would say it outputs true but it actually output false which means $var is "". But it is not, its integer 0
So, is "" same as integer 0 if not comparing by type using !==
Are these all empty values when comparing using $var != "":
$var = 0
$var = "0"
$var = array()
$var = ""
$var = null
$var false
empty values
Moderator: General Moderators
-
mikecampbell
- Forum Commoner
- Posts: 38
- Joined: Tue Oct 12, 2010 7:26 pm
Re: empty values
See http://ca3.php.net/manual/en/language.o ... arison.phpAre these all empty values when comparing using $var != "":
$var = 0
$var = "0"
$var = array()
$var = ""
$var = null
$var false
The following are true:
0==""
0==null
""==null
0==false
""==false
false==null
0=="0"
false=="0"
array()==false
array()==null
The following are not true:
array()==0
array()=="0"
"0"==null
"0"==""