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

From: Date: Fri, 09 Feb 2001 17:34:54 +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-46093@lists.php.net to get a copy of this message
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 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 === , on the other hand, works like this: if left-hand-type != right-hand-type result is false else compare unconverted left-hand-argument to unconverted right-hand-argument -- Hartmut Holzgraefe hartmut@six.de http://www.six.de +49-711-99091-77 Besuchen Sie uns auf der CeBIT 2001 - in Halle 6 Stand F62/4

« previous php.dev (#46093) next »