note 40213 deleted from language.operators.bitwise by danielc
| From: | danielc@php.net | Date: | Mon, 13 Apr 2009 16:12:06 +0000 |
| Subject: | note 40213 deleted from language.operators.bitwise by danielc | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-153158@lists.php.net to get a copy of this message | ||
Note Submitter: crizza at sdf dot lonestar dot org
Reason: 0
----
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.