Re: odd behavior of stripos() with === operator *UPDATE*

From: Date: Fri, 17 Nov 2006 09:39:30 +0000
Subject: Re: odd behavior of stripos() with === operator *UPDATE*
References: 1 2 3  Groups: php.general 
Request: Send a blank email to php-general+get-244782@lists.php.net to get a copy of this message
Please include the list in replies. Michael wrote:
Why can't === realize that integer 0 means TRUE? whereas "" or a BOOLEAN false does not? === evaluates integer 0 to FALSE :( the !== operator recognizes the difference. "(integer) 0 !== FALSE" is TRUE yet "(integer) 0 === TRUE" is FALSE, but it should also be TRUE. follow? or am I really stupid heh I value your opinion on this and if you need to take a stick to me to straighten me out, feel free :)
A stick? Can do! You've said it yourself... "(integer) 0 === TRUE" is FALSE, but it should also be TRUE. This comparison says... Is the INTEGER 0 equal in both value *and* type to the BOOLEAN true? The answer of course is no. In exactly the same way that any comparison of different types using === will be false. Note that this has absolutely nothing to do with the fact that the value you are comparing has come from strpos, it is a basic language feature. And it's not my opinion, it's a fact. If that doesn't make it clear then I really don't know what will. -Stut

« previous php.general (#244782) next »