Re: wierd if statments

From: Date: Thu, 26 Oct 2000 22:22:05 +0000
Subject: Re: wierd if statments
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-22220@lists.php.net to get a copy of this message
Julia A . Case writes: > An interesting aside, if you change $tmp1 to $tmp1=1 then it returns false. > > Julie True--that's because when a string is converted to an integer, the integer value is taken from any digits before the first non-digit character in the string. For example, "23Bob" would become 23, and so forth. Since "all" has no digits before the first non-digit, it evaluates to 0. Thus, 0 == "all" is true, but 1 == "all" is false, since PHP sees it as 1 == 0. > Quoting Chris Lee (lee@mediawaveonline.com): > > <? > > $tmp1 = 0; > > $tmp2 = "all"; > > > > if ($tmp1 == $tmp2) > > echo "TRUE<br>\n"; > > else > > echo "FLASE<br>\n"; > > ?> > > > > Whats going on here, this returns TRUE !!! > > > > Chris Lee -- +----------------------------------------------------------------+ |Torben Wilson <torben@php.net> Netmill iTech| |http://www.coastnet.com/~torben http://www.netmill.fi| |Ph: 1 250 383-9735 torben@netmill.fi| +----------------------------------------------------------------+

« previous php.general (#22220) next »