If I remember correctly, the string is cast as an integer for the comparison
when you use ==

And the integer value of a string is 0.

Try this: echo (int)"php"

You can use strict type matching with === and you'll get a more accurate
result, but keep in mind that "1" == 1 is false because one's a string and
the other isn't...



2009/2/12 Cam Spiers <[email protected]>

> Hi,
>
> I came across this today
>
> The following result in true:
> "php" == TRUE
> "php" == 0
>
> The following result in false:
> "php" == FALSE
> "php" == 1
>
> This to me is an unusual behavior especially considering 1 == TRUE and 0 ==
> FALSE
>
> Can anyone shed some light on this, maybe this behavior makes sense to
> some, but not to me.
>
> Cheers,
> Cam
>
> >
>


-- 
Chris Hope
The Electric Toolbox Ltd

Email: [email protected]
Web: www.electrictoolbox.com
Phone: +64 9 522 9531
Mobile: +64 21 866 529

--~--~---------~--~----~------------~-------~--~----~
NZ PHP Users Group: http://groups.google.com/group/nzphpug
To post, send email to [email protected]
To unsubscribe, send email to
[email protected]
-~----------~----~----~----~------~----~------~--~---

Reply via email to