Hi all!
I've just a short question. As im using some binary comparison in order to check which part of my homepage is visible for the user i want to compare two values against each other.
Short example:
I've got the following visible levels:
Guest = 2 = 001 Binary
Registered = 4 = 010 Binary
Admin = 8 = 100 Binary.
Now when i want an Element of the homepage to be visible only for Registered users and admins i will assign the value 12 (which is 110 Binary).
When it comes to the visible desission i thought i can do the following operation:
$visibleTo = 12; //Element should be visible to Admin and registered user
$currentUserVisibleLevel = 8; //user is admin
$elementIsVisible=($visibleTo & $currentUserVisibleLevel) > 0;
//expected:
//$elementIsVisible = 8 or at least greater then 0
//because 12 & 8 == 110 & 100 = 100 = 8
echo "result:".$elementIsVisible."!"; //prints result:!
What am i doing wrong??
Thanks in advance and Greets
Hotkey