Re: PHP 4.0 Bug #9186 Updated: string compare with "==" does not work correctly

From: Date: Fri, 09 Feb 2001 17:37:51 +0000
Subject: Re: PHP 4.0 Bug #9186 Updated: string compare with "==" does not work correctly
References: 1 2 3  Groups: php.dev 
Request: Send a blank email to php-dev+get-46095@lists.php.net to get a copy of this message
At 19:34 9/2/2001, Hartmut Holzgraefe wrote:
Alan van den Bosch wrote: == is (has become?) a boolean logic operator, dealing in terms of 'true' and 'false' values, so its terms are type cast to either 'true' or 'false'. When applied to strings, a 'false' string is zero length or contains '0', all other strings are 'true'. the result of == is boolean, not the arguments expected behaviour could be: if left-hand-type != right-hand-type convert right-hand-argument to left-hand type compare left-hand-argument to possibly converted right-hand-argument
There's no (and shouldn't be any) significance in the order of the arguments.
additionaly, IMHO, as php has to deal with html forms a lot and html has no <input type=numeric> there are a lot of places where a string that qualifies as is_numeric is silently treated as a numeric argument
Right, that's why PHP automatically compares two string-like strings as if they were numbers. Zeev

« previous php.dev (#46095) next »