Date: 08/07/00
- Next message: Chris Adams: "Re: [PHP] $VAR = 0 != false"
- Previous message: Tiefeng Jia: "[PHP] php3_ftp.dll compile error"
- Next in thread: Chris Adams: "Re: [PHP] $VAR = 0 != false"
- Reply: Chris Adams: "Re: [PHP] $VAR = 0 != false"
- Reply: Andre Fadel: "Re: [PHP] $VAR = 0 != false"
- Reply: Daniel Convissor: "Re: [PHP] $VAR = 0 != false"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi *,
I have an ecommerce site where the shopping cart supports options for items.
One of the items has an option that is stored in the database as 0 (zero). It doesn't mean false, it means that an option was selected, and the option was 0.
If I echo out the variable, you get "0" echoed out.
$VAR = "0";
echo $VAR;
You get what you would expect.
But, if you verify the variable exists first:
if($VAR){
echo $VAR;
}
You get nothing, even though the variable is set. It is set to zero, granted, but it is set!
I can understand that in some types of tests you want 0 to be synonimous with false, but here I am only testing if the variable is set to a value, be it false, 0, or something else.
I just tested, and isset() works like I think it should (I am NOT the source of all truth and knowledge, just trying to make this make sense), but !empty() does not:
if(!empty($VAR)){
echo $VAR;
}
even though $VAR isn't empty.
Thoughts, comments, flames?
Thanks,
Brian
- Next message: Chris Adams: "Re: [PHP] $VAR = 0 != false"
- Previous message: Tiefeng Jia: "[PHP] php3_ftp.dll compile error"
- Next in thread: Chris Adams: "Re: [PHP] $VAR = 0 != false"
- Reply: Chris Adams: "Re: [PHP] $VAR = 0 != false"
- Reply: Andre Fadel: "Re: [PHP] $VAR = 0 != false"
- Reply: Daniel Convissor: "Re: [PHP] $VAR = 0 != false"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

