note 31602 deleted from language.operators by sniper
| From: | sniper@php.net | Date: | Mon, 13 Oct 2003 00:05:18 +0000 |
| Subject: | note 31602 deleted from language.operators by sniper | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-58366@lists.php.net to get a copy of this message | ||
Note Submitter: Bernard Blundell
----
Don't get caught out by the syntactically correct (but usually wrong) beginner's way of
range testing:
if ($a <= $b <= $c) {
// OOPS
}
The problem is that ($a <= $b) evaluates to 0 or 1, then ((0 or 1) <= $c) is used to determine
the whole expression.
Obviously, you need to do this:
if ($a <= $b && $b <= $c) {
// woo and yay
}