OK I have a very strange bug:

In the middle of my script I have these two lines:

var_dump($test,$test2);
echo "'$test'=='$test2' is ".($test==$test2);

which is giving:

int(0) string(6) "Points"
'0'=='Points' is 1

I understand that PHP is loose typed and automatically does type conversion but in the many years I've been using PHP (mostly v4) the comparison had always converted to 'string' and in the case above returned FALSE, not TRUE. It seems here they are comparing as integers thus 'Points' evaluates to 0 and the comparison is TRUE.

I tried comparing in the reverse sequence ($test2==$test) and the same occurred. It does work as expected if I have === but the rest of the scirpt isn't type sensitive so I want NULL, 0, and empty string to still maintain equality.

Any ideas why this is suddenly happening? I'm using PHP 5.1, and I realize I could use other functions such as strval() in the comparison however I've used similar logic in the past without problems.

Any help would be great.

Thanks

Jeff



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jeffrey Sambells
Director of Research and Development
Zend Certified Engineer (ZCE)

We-Create Inc.
[EMAIL PROTECTED] email
519.745.7374 x103 office
519.897.2552 mobile

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Get Mozilla Firefox at
http://spreadfirefox.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to