note 40213 added to language.operators.bitwise
| From: | crizza at sdf dot lonestar dot org | Date: | Wed, 25 Feb 2004 16:27:23 +0000 |
| Subject: | note 40213 added to language.operators.bitwise | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-65735@lists.php.net to get a copy of this message | ||
Personally I get a great deal of pleasure using bitwise operators for dealing with flags
here is an example using c code because im a php noob, but the principal of bitwise ops is the same.
#define F_WITH_DEBUG 0x01
#define F_WITH_HELP_INFO 0x02
#define F_BE_VERBOSE 0x04
unsigned short flags = 0;
flags |= ( F_WITH_DEBUG | F_WITH_HELP_INFO | F_BE_VERBOSE );
/* now the first byte of flags look like this 00000111 */
/* check the status of flags */
if( flags & F_WITH_DEBUG) {
/* do something */
}
flags are great, I love *them.
----
Manual Page -- http://www.php.net/manual/en/language.operators.bitwise.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+40213
Delete -- http://master.php.net/manage/user-notes.php?action=delete+40213&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+40213&report=yes
Search -- http://master.php.net/manage/user-notes.php