note 62654 rejected from language.operators.bitwise by bjori

From: Date: Mon, 06 Mar 2006 15:54:23 +0000
Subject: note 62654 rejected from language.operators.bitwise by bjori
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-104908@lists.php.net to get a copy of this message
Note Submitter: velesin ---- 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.

« previous php.notes (#104908) next »