# Permission
7 read and write and execute (1+2+4)
6 read and write (2+4)
5 read and execute (1+4)
4 read only
3 write and execute (1+2)
2 write only
1 execute only
0 none
值我喜歡你可以的選項選項的任意組合存儲在一個整數,和由最後一個數字(8,16,32等)加倍添加選項的模式。 我想使用這種方法,我想知道它是否有名稱,以及將數字轉換爲類似於此結果的最簡單方法是什麼?讀CHMOD像用PHP
array(1=>false,2=>true,4=>true);//6
array(1=>true,2=>true,4=>true,8=>true);//15
http://en.wikipedia.org/wiki/Bit_field – 2011-02-16 05:20:50
相關咆哮:http://stackoverflow.com/questions/224799/bitwise-flags-abandoned – 2011-02-16 05:25:50