Re: Re: [RFC] Comparison and conversion inconsistency - need more info
| From: | Yasuo Ohgaki | Date: | Sun, 10 Nov 2013 21:32:43 +0000 |
| Subject: | Re: Re: [RFC] Comparison and conversion inconsistency - need more info | ||
| References: | 1 2 3 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70096@lists.php.net to get a copy of this message | ||
Hi Stas,
On Mon, Nov 11, 2013 at 6:17 AM, Stas Malyshev <smalyshev@sugarcrm.com>wrote:
> > TRUE always evaluated as 1. I guess I've checked this behavior and made
> > wrong assumption
> > FALSE/NULL is always evaluated as 0, but it's not.
>
> True is not evaluated as 1, 1 is evaluated as true. When you compare
> with bool, other side is converted to bool. Which is described in the
> manual :) Try the same with -17, you'd get the same result, since -17 is
> bool-eanized as true.
bool or null anything Convert to bool, FALSE < TRUE
I was reading null gets converted to bool, but it's on both ops.
It's surprising to me that I've never bitten by this misunderstanding :(
Thank you for your time.
--
Yasuo Ohgaki
yohgaki@ohgaki.net