Re: possible bug (string equality to zero)?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Christopher J. Bottaro wrote:
Is it a bug that ($var == 0) is always true for any string $var?

For any string? How about the string 5? :-)

PHP tries to help you out, but there's not much it can do when you ask it to compare a string like 'foo' to an integer. It scans your string from left to right and uses the leading numbers to create the integer. For example, 53chris is 53, but chris53 is 0 (no leading numbers).

Hope that helps.

Chris

--
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux