Bitwise Declaration of Flags
| From: | Clint Priest | Date: | Sun, 27 Sep 2009 05:13:24 +0000 |
| Subject: | Bitwise Declaration of Flags | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-45638@lists.php.net to get a copy of this message | ||
Are there any plans to allow bitwise declaration of flags?
Example:
class foo {
const FLAG_1 = 1;
const FLAG_2 = 2;
const FLAG_3 = 4;
private $Flags = self::FLAG_1 | self::FLAG_3
}
The above doesn't work, gets a syntax error on the | operator.
Has anyone thought about a change to allow this type of functionality?
I end up doing something like this which is less than optimal
private $Flags = 3 /* self::FLAG_1 | self::FLAG_3 */
Thanks,
-Clint