note 31602 added to language.operators

From: Date: Sun, 27 Apr 2003 21:48:07 +0000
Subject: note 31602 added to language.operators
Groups: php.notes 
Request: Send a blank email to php-notes+get-47182@lists.php.net to get a copy of this message
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 } -- http://www.php.net/manual/en/language.operators.php http://master.php.net/manage/user-notes.php?action=edit+31602 http://master.php.net/manage/user-notes.php?action=delete+31602 http://master.php.net/manage/user-notes.php?action=reject+31602

« previous php.notes (#47182) next »