ok, now it's clear why i must use '|' instead of '+'. 
i still couldn't get what happens with bits but you
don't have to explain more. i know that it's about
bitwise operators, and how they handle numbers. no!
ok! i just got it! 
thank you again.

--- bob parker <[EMAIL PROTECTED]> wrote:
> Couple of points:
> You really do need to use the '!' operator to
> combine the categories not '+'
> eg if your user entered 2 twice you would get 
> $userLevels = 2 + 2;  // wrong we just made our admin
> a writer
> but
> $userLevels = 2 | 2;  // ok is still admin because
> $userLevels is still 2
> 
> These operators, | and & are called bit wise
> operators to see how they
> work look at the binary representations of the
> numbers
> say $userlevel = 15 then in binary
> $userlevel is 1111
> $result = 1111 & 0001;        // $result is 0001 binary or
> decimal 1
> $result = 1111 & 0010;        // $result is 0010 binary or
> decimal 2
> $result = 1111 & 0100;        // $result is 0101 binary or
> decimal 4
> $result = 1111 & 1000;        // $result is 1000 binary or
> decimal 8
> the '&' operator only returns the bit or bits which
> are both 1 in the
> same column.
> 
> The or operator returns the bits which are 1 in
> ether column so
> 2 | 2 which is 0010 | 0010 still returns 0010 which
> is 2
> Hope this helps
> bob

__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to