ID: 9186
User Update by: [EMAIL PROTECTED]
Status: Analyzed
Bug Type: Documentation problem
Description: string compare with "==" does not work correctly

Ok, I accept this. But I don't think that is a good idea 
to compare apples with pears with the answer 'yes they are 
fruit' without any warning.

Previous Comments:

[2001-02-15 04:32:00] [EMAIL PROTECTED]
Ok, it should remain open as a documentation problem...


[2001-02-15 04:31:01] [EMAIL PROTECTED]
This is a defined behavior (and does have strong reasons).  It's not a bug.
If you're interested in a byte-by-byte string comparison, you should use strcmp().


[2001-02-09 11:10:17] [EMAIL PROTECTED]
Incorrectly flagged as bogus.


[2001-02-09 10:59:10] [EMAIL PROTECTED]
I think there is no reason to convert any type if both 
operands of the comparision are of the same type. It costs 
time and it's completely not necessary. This is a bug.

I can not see any description of this behavior in the 
manual. The string type section descibes only what is 
happen if a string is converted.


[2001-02-09 10:27:46] [EMAIL PROTECTED]
Actually, this is a feature - it is described in the manual. Strings that look like 
numbers are converted to numbers. Large numbers - like the ones below may not convert 
perfectly from a string to a number.  Review the manual section on PHP types in 
general and strings in particular 

While this is a relatively subtle bug, you can ensure that you are dealing with 
strings by quoting the variables being compared or by using the === operator.  This 
behavior is exploited quite often in PHP scripts.  However, perhaps it would be nice 
if PHP generated an notice level error when it occured so that users have some 
recourse when it happens unexpectedly.

If you feel strongly about this, propose it to the developers as a feature request.  
Post your request on the [EMAIL PROTECTED] list (sub at 
[EMAIL PROTECTED]) - if you get no response, be polite but persistant. :)


The remainder of the comments for this report are too long.  To view the rest of the 
comments, please view the bug report online.

Full Bug description available at:

PHP Development Mailing List <>
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