I think this is happening because you're comparing apples to oranges.
Your first comparison causes an integer to be compared to a string.
Because the string "string" evaluates to the integer value 0, the
comparison succeeds. The manual recommends the use of the identical
comparison operator (===) instead, or--better yet--the strcmp() function
when comparing two strings.
Cheers,
Marco
--
------------
php|architect - The magazine for PHP Professionals
The monthly worldwide magazine dedicated to PHP programmers
Come visit us at http://www.phparch.com!
--- Begin Message ---
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
--- End Message ---
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php