I saw in school a system that set permissions using binary string.
Let\'s say 101001 = 41
So :
You can use & operator and check against those flags.
$READ = 8;
$WRITE = 1;
$EXECUTE = 32;
$permissions = 41;
if ($permissions & $READ) {
// do smth
}
if ($permissions & $WRITE ) {
// do smth
}
if ($permissions & $EXECUTE ) {
// do smth
}
Let me explain it. If you have bits 1001 (9). You just check forth bit (1000) with 1001. You just multiply EVERY bit of $permissions variable and bit number. Result will be 1000. It's convertible to true value. So you have flag here. If check third bit (0100) it will result in 0000 and it's false value. So you haven't got permissions here.