Binary refresher needed

From: Date: Sun, 29 Aug 2004 23:10:40 +0000
Subject: Binary refresher needed
Groups: php.general 
Request: Send a blank email to php-general+get-195111@lists.php.net to get a copy of this message
Okay, I need a reminder on this. A given variable can consist of two constants ORd together, say TEST1 and TEST2. If I'm looking to see if one of the constants was set in the variable, I use &, right? if(($value & TEST1) == TEST1) { echo 'TEST1 flag was set.'; } if(($value & TEST2) == TEST2) { echo 'TEST2 flag was set.'; } I know that works, but is that the best way? Been a while since I played with this... :) -- ---John Holmes... Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/ php|architect: The Magazine for PHP Professionals – www.phparch.com

« previous php.general (#195111) next »