Is it a bug that ($var == 0) is always true for any string $var?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
[snip]
Is it a bug that ($var == 0) is always true for any string $var?
[/snip]
You are comparing a string to an integer.
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
No, Christopher, that is not a bug. As long as the var is empty, and if
you try to compare with 0, or false, it will report true in the
comparison because the variable does not contain anything, which will
mean false for a boolean and 0 for a variable. If you are attempting to
discover if a string
[snip]
Is it a bug that ($var == 0) is always true for any string $var?
[/snip]
You are comparing a string to an integer.
Right. This is clearly documented at http://www.php.net/operators.comparison
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit:
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
Hi,
Is it a bug that ($var == 0) is always true for any string $var?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Check this out!
http://us3.php.net/manual/en/types.comparisons.php
--
PHP General Mailing List
6 matches
Mail list logo