Re: [RFC] Comparison and conversion inconsistency - need more info
| From: | Rowan Collins | Date: | Sun, 10 Nov 2013 19:44:19 +0000 |
| Subject: | Re: [RFC] Comparison and conversion inconsistency - need more info | ||
| References: | 1 2 3 4 5 6 7 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70084@lists.php.net to get a copy of this message | ||
On 10/11/2013 10:18, Yasuo Ohgaki wrote:
Yes, but the result differs when comparison is done as expression. (e.g. if (expression))I can't find any discrepancy with how NULL behaves (as others have pointed out, your earlier example was echoing the wrong message). However, it does seem that TRUE behaves differently, based on the test code below (see http://3v4l.org/7HGVI for full results):
function which_is_lower($a, $b) {Givingif ( $a < $b ) { return $a; } else { return $b; }} function compare_comparisons($a, $b) {echo 'min() gives: '; var_dump( min($a, $b) ); echo 'comparison with < gives: '; var_dump( which_is_lower($a, $b) );} echo "\n", '-1 vs TRUE: ', "\n"; compare_comparisons(-1, TRUE);
-1 vs TRUE: min() gives: int(-1) comparison with < gives: bool(true)-- Rowan Collins [IMSoP]