When you define $no, you define it without quotes, so PHP assumes it is a numeral. What you're asking in your conditional statement is: Does the numeral 0 equal the integer evaluation of "string". The answer is True.
But when you put $no into quotes you cast it as a string. Now what you're asking is Does the string "0" equal the string "string". The answer is False. -Kevin ----- Original Message ----- From: "Scott Hurring" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, December 13, 2002 12:27 PM Subject: [PHP] Question about "if" statement evaluating (0=="string") as TRUE > Erm... this seems a bit odd to me. I'm using PHPv4.2.2 on Win32 > > Is that becuase PHP is not properly comparing the numerical value with > the string value? > > <? > $no = 0; > if ($no == "string") { > print "this eval's to TRUE... since when is '0' == 'no' ?"; > } > if ("$no" == "string") { > print "whereas this eval's to FALSE, as you'd expect"; > } > ?> > > > > -- > Scott Hurring > Systems Programmer > EAC Corporation > scott (*) eac.com > -- > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php