At 02:10 AM 11/17/2006 , Stut wrote:
>Michael wrote:
>> Ok, picking gnits...
>> I should have said NOT true and NOT false at the same time.
>> As for the return of the integer 0..
>> The documentation indicates that the === and !== operators take this into
>> account in fact there is a specific example in the manual.
>>
>> My point here is that if !== works , why does === not?
>>
>
>I think you need to re-read the docs for ===.
>
> 0 !== false
>
> 0 == false
>
> 1 == true
>
> 1 !== true
>
>only...
>
> false === false
>
>and
>
> true === true
>
>The === and !== check both value and type, so 0 and false are different.
>
>Hope that helped.
>
>-Stut
>
>--
Thanks for your reply Stut.
I understand that the integer 0 and FALSE are different and I read the manual
so many times my head hurts, heh.
There are a few ways to work around this, probably more than I know. (according
to the documentation for strrpos() you could test the return from stripos() for
is_bool before using it), or (perhaps, cast the return from stripos() to a
boolean, although integer 0 probably casts to false :/, I honestly didn't test
this {see >>>}), or (easiest solution...just suck up and use !== FALSE all the
time :D )
My point in posting this was threefold,
1) to help others who may not know that stripos() returns an INTEGER 0 when the
needle is found at the beginning of haystack, and/or don't realize the
implications of that.
2) My main point is that !== works, so should ===. If !== knows the difference
between integer 0 and boolean FALSE, why doesn't ===?
3) to get feedback from the community and deepen my understanding of PHP.
So, I thank you very much for your reply :)
Regards,
Michael
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php