Re: Re: [RFC] Comparison and conversion inconsistency - need more info
| From: | Sanford Whiteman | Date: | Sun, 10 Nov 2013 20:28:33 +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-70090@lists.php.net to get a copy of this message | ||
> I still didn't get it right :(
Please, please read the documentation for comparison, juggling, and
precedence.
> [yohgaki@dev ~]$ php -r "var_dump((TRUE > 100));"
> bool(false)
Equiv to TRUE > TRUE
> [yohgaki@dev ~]$ php -r "var_dump((TRUE < 100));"
> bool(false)
Equiv to TRUE < TRUE
> [yohgaki@dev ~]$ php -r "var_dump((TRUE > -100));"
> bool(false)
Equiv to TRUE > TRUE
> [yohgaki@dev ~]$ php -r "var_dump((TRUE < -100));"
> bool(false)
Equiv to TRUE < TRUE
> TRUE/FALSE only evaluated as 1/0 otherwise always return FALSE in
> expression.
You must stop phrasing it that way -- that may be accidentally correct
for some situations but it is not "the rule."
> [yohgaki@dev ~]$ php -r "var_dump((NULL < -100));"
> bool(true)
Equiv to FALSE < TRUE
> [yohgaki@dev ~]$ php -r "var_dump((NULL > -100));"
> bool(false)
Equiv to FALSE > TRUE
> NULL behaves differently, though.
Differently from what? It's exactly as specified in the docs.
-- S.