Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我为这样的人授予权限:
$ARR_PERSON = array( 2 => "Person B", 4 => "Person C", 8 => "Person D", 16 => "Person E", 32 => "Person F", );
问题是我有号码时不知道如何获得许可。例如: 24. 如何拆分成 8 和 16?我想不出解决办法。
使用按位运算。当PERMISSION & MASK为非零时(例如,24 & 16),设置标志。当它为零时,不设置标志。
PERMISSION & MASK
24 & 16