note 62654 added to language.operators.bitwise

From: Date: Mon, 06 Mar 2006 14:35:48 +0000
Subject: note 62654 added to language.operators.bitwise
Groups: php.notes 
Request: Send a blank email to php-notes+get-104903@lists.php.net to get a copy of this message
To check if $a, $b, $c and $d are all equal, You don't have to test so many cases. Equality is a transitional relationship, so if: $a == $b && $a == $c && $a == $d or: $a == $b && $b == $c && $c == $d it's the same as if You'd check all combinations: $a == $b && $a == $c && $a == $d && $b == $c && $b == $d && $c == $d (last 3 are not necessary) You can write it even shorter: $a == $b == $c == $d Test ($a & $b & $c & $d) == $a is wrong. If, f.e.: $a = 1; $b = 3; $c = 3; $d = 3; this test will pass (bacause 1 & 3 & 3 & 3 is equal to 1 which is equal to $a) while it shouldn't - values are not equal. ---- Server IP: 66.163.161.117 Probable Submitter: 217.173.167.157 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/language.operators.bitwise.php Edit -- http://master.php.net/note/edit/62654 Del: integrated -- http://master.php.net/note/delete/62654/integrated Del: useless -- http://master.php.net/note/delete/62654/useless Del: bad code -- http://master.php.net/note/delete/62654/bad+code Del: spam -- http://master.php.net/note/delete/62654/spam Del: non-english -- http://master.php.net/note/delete/62654/non-english Del: in docs -- http://master.php.net/note/delete/62654/in+docs Del: other reasons-- http://master.php.net/note/delete/62654 Reject -- http://master.php.net/note/reject/62654 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#104903) next »