In message <[EMAIL PROTECTED]>, Jim
MacDiarmid <[EMAIL PROTECTED]> writes
>
>
>I'm trying to roll my own CMS and have an integer field in my user database
>that I want to be able to set bits or turn on and off flags based on what
>permissions the user or group has. My test code is below but doesn't seem
>to be working for comparison purposes to see if a user has a particular
>permission.
>Has anyone done anything like this in PHP? Any ideas what I'm doing wrong?
>
>define('PERM1', 1);
>define('PERM2', 2);
>define('PERM3', 4);
>define('PERM4', 6);
>define('PERM5', 8);
>define('SOME_PERMS', PERM1 | PERM3 | PERM4 | PERM5); // should be 19
>define('ALL_PERMS', PERM1 | PERM2 | PERM3 | PERM4 | PERM5);
>
>$flags = ($flags | SOME_PERMS);
>echo $flags . "<BR>";
>echo ( $flags & PERM2 );
This is something that I have never tried in this context, but the bits
are not
1,2,4,6,8
but
1,2,4,8,16
Also, you might get some ideas from
http://www.shawnolson.net/a/601/
who only goes as far as
1,2,4,8 (no 16, but the principle is the same)
--
Pete Clark
http://www.hotcosta.com
http://www.spanishholidaybookings.com
Community email addresses:
Post message: [email protected]
Subscribe: [EMAIL PROTECTED]
Unsubscribe: [EMAIL PROTECTED]
List owner: [EMAIL PROTECTED]
Shortcut URL to this page:
http://groups.yahoo.com/group/php-list
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/php-list/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/