|
Posted by Michael B. Trausch on 07/08/05 21:29
Tom Thackrey wrote:
>
> The problem is you aren't using the bitwise operators. & is not bitwise, &&
> is
>
> Also, you don't need the >0, if ($pref && USER_ADMIN) will work just fine
> and won't have a problem if you use the high order bit as a flag.
>
Am I misreading the documentation, then? According to
http://us3.php.net/manual/en/language.operators.bitwise.php the &
operator is bitwise AND, and according to
http://us3.php.net/manual/en/language.operators.logical.php the &&
operator is logical AND.
Or, am I misunderstanding the definition of logical AND in PHP? I don't
want (TRUE and TRUE), I want (0xffffffff & 0x00000001) where the output
of the expression should be 0x00000001 (1) and hence greater then zero,
returning true.
The way I am understanding the published documentation, which states the
following, is that the above should work. There appears, however to be
a flaw in that logic:
$a & $b And Bits that are set in both $a and $b are set.
(from http://us3.php.net/manual/en/language.operators.bitwise.php)
In other words, the way I read the documentation, it should be the same
operators that you use in C (&& expression evaluation, and & for bitmask
comparisons).
Incidentally, if I replace & with && in the code, it still doesn't work
properly. If the user running the code is USER_SEEKER, it works just
fine, returning the user ID as it should and then the page that I'm
working on, well, works. However, if the user is anything other then
USER_SEEKER, the function fails to return anything but an apparently
empty value. If the user has no cookie, it works as it should, although
I do not know if this is consequental or incidental to something else.
- Mike
[Back to original message]
|