Bug #9186 Updated: string compare with "==" does not work correctly
| From: | danbeck@php.net | Date: | Wed, 27 Jun 2001 04:43:32 +0000 |
| Subject: | Bug #9186 Updated: string compare with "==" does not work correctly | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-58142@lists.php.net to get a copy of this message | ||
ID: 9186
Updated by: danbeck
Reported By: tom.anheyer@berlinonline.de
Old-Status: Analyzed
Status: Closed
Bug Type: Documentation problem
Operating system:
PHP Version: 4.0.4pl1
Assigned To:
Comments:
I'm not sure why this is still open as a documentation bug.
The string behavior is documented in:
http://www.php.net/manual/en/language.types.string.php
and the == and === behavior is documented in:
http://www.php.net/manual/en/language.operators.comparison.php
Previous Comments:
---------------------------------------------------------------------------
[2001-02-15 05:38:18] tom.anheyer@berlinonline.de
The conversation is useful. I know this because HTML form
parameters, MySQL result sets are strings even if they are
represent numbers.
But there some cases for which the conversation is not
useful. If the result is MAXINT, MININT or NaN, it would
be better not converting the operands and making a
string comparision. A warning message whould be also
useful.
---------------------------------------------------------------------------
[2001-02-15 05:25:09] hholzgra@php.net
this autoconversion is usefull when dealing with html form input
(for which php is used every once in a while afaik :)
as html has no numric input elements, just text
maybe it would make sense to have this behaviour configurable
in the ini file, but i'm afraid that this would only increase the WTF
factor even more
---------------------------------------------------------------------------
[2001-02-15 05:07:35] tom.anheyer@berlinonline.de
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.
---------------------------------------------------------------------------
[2001-02-15 04:32:00] zeev@php.net
Ok, it should remain open as a documentation problem...
---------------------------------------------------------------------------
[2001-02-15 04:31:01] zeev@php.net
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().
---------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view the rest of the comments,
please view the bug report online.
ATTENTION! Do NOT reply to this email!
To reply, use the web interface found at http://bugs.php.net/?id=9186&edit=2