RE: [PHP] if (a == b) ...

From: Date: Thu, 30 Jan 2003 01:39:01 +0000
Subject: RE: [PHP] if (a == b) ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-133577@lists.php.net to get a copy of this message
> I have a conditional: > if (a == b) > > a is the number 0, but b is a string "Friday August 22". > > The condition is evaluating as true, which is not what I want. > What am I misunderstanding? You're comparing a string to a number perhaps? I tried this: -----8<----- $a = 0; $b = "Friday August 22"; if ($a == $b) { echo "match"; } else { echo "no match"; } -----8<----- and resulted in 'match', then I tried this: -----8<----- $a = "0"; $b = "Friday August 22"; if ($a == $b) { echo "match"; } else { echo "no match"; } -----8<----- and resulted in 'no match'. It's worth remembering that the number 0 has somewhat special meaning in php as a true/false indication. CYA, Dave

« previous php.general (#133577) next »