note 61381 deleted from language.operators.bitwise by bjori
| From: | bjori@php.net | Date: | Thu, 27 Apr 2006 09:39:36 +0000 |
| Subject: | note 61381 deleted from language.operators.bitwise by bjori | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109841@lists.php.net to get a copy of this message | ||
Note Submitter:
----
It can be interesting to use & operator to test if many vars have the same value or not.
<?php
$a = 123 ;
$b = 1234 ;
$c = 123 ;
$d = 123 ;
// Take care to & priority lower than == priority
if ( ($a & $b & $c & $d) == $a ) {
echo 'all equal' ;
} else {
echo 'not all equal' ;
}
?>
Much more shorter than :
<?php
if ( $a == $b && $a == $c && $a == $d && $b == $c && $b == $d
&& $c == $d ) {
[...]
?>