|
Posted by Chris Shiflett on 08/11/05 19:06
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/
Navigation:
[Reply to this message]
|