note 61381 added to language.operators.bitwise

From: Date: Thu, 02 Feb 2006 00:49:40 +0000
Subject: note 61381 added to language.operators.bitwise
Groups: php.notes 
Request: Send a blank email to php-notes+get-102849@lists.php.net to get a copy of this message
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 ) { [...] ?> ---- Server IP: 217.174.203.10 Probable Submitter: 82.228.123.113 ---- Manual Page -- http://www.php.net/manual/en/language.operators.bitwise.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+61381 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+61381&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+61381&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#102849) next »