OK, I was way off base in my reasoning... :-)

Thanks for the clarification Zeev and Zak.


> How is this? I modified what Zeev said a wee bit:
> == is a 'loose' comparison operator [1].
> In most cases, this is more convenient - the operator does the right thing
> without needing any coaxing.  In some cases, things will happen that are
> confusing - particularly when comparing values that have leading zeros (0)
> or when comparing very long numbers that are inside a string.
> The basic rule to follow is this:
> Character-by-character comparison is performed only if both arguments are
> strings and at least one of the strings does not look like a number [2].
> Another way to state this rule is:
> - If at least one of the arguments is not a string, a numeric comparison
> made.
> - If both arguments are strings, but both of them look like numbers, a
> numeric comparison is made.
> - If both arguments are strings (and at least one of them doesn't look
> a number), a string comparison is made.
> [1] If you need to perform an exact comparison between two values, take a
> look at the 'strict' comparison operator (===) and the strcmp() function.
> [2] See the manual section on types and strings to learn what rules PHP
> follows for recognising numbers within strings.
> (Thanks to Zeev for clarifying this issue.)
> --zak

PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to