Re: PHP 4.0 Bug #9186 Updated: string compare with "==" does not work correctly
| From: | Zeev Suraski | Date: | Fri, 09 Feb 2001 17:53:25 +0000 |
| Subject: | Re: PHP 4.0 Bug #9186 Updated: string compare with "==" does not work correctly | ||
| References: | 1 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-46097@lists.php.net to get a copy of this message | ||
Yep, we should. It came up many times over the years, this behavior haven't changed since early PHP 3.0.0...
Zeev
At 19:47 9/2/2001, Zak Greant wrote:
Zeev Suraski wrote: At 17:59 9/2/2001, tom.anheyer@berlinonline.de wrote:-- Zeev Suraski <zeev@zend.com> CTO & co-founder, Zend Technologies Ltd. http://www.zend.com/ID: 9186 User Update by: tom.anheyer@berlinonline.de Status: Bogus Bug Type: Scripting Engine problem Description: string compare with "==" does not work correctly 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.No, it's not a bug. It's definitely an intended behavior. PHP does it's best to do the 'right thing' in the most common cases. Because of the way it works, effectively, comparing strings that 'look like numbers' as if they were numbers makes life much, much easier. If you want to enforce a string comparison, use strcmp().We should document this behavior then - it could lead to problems that are very hard to track down!--zak