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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux