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 );

Thanks much,
Jim




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/
 


Reply via email to