At 05:54 08.03.2003, James Taylor said: --------------------[snip]-------------------- >Ok, this may have already been posted to the list already, but the >archives don't seem to like the & and && characters. > >I'm running into some code that looks like this: > ><snip> >Define('INPUT', 2); ><snip> >if($search->level & INPUT) $tmp.= $search->input(); > > >Ok, what's the & mean? > >As far as I could tell from the very little documentation I was able to >scrape up on google, & is a bit-by-bit operator. Thus, if either INPUT >or $search->level, we get TRUE... If that's the case, what's the point >of using it instead of || ? --------------------[snip]--------------------
These are two totally different operators: & - bitwise AND && - logical AND So: 5 && 2 yields true 5 & 2 yields 0 In your example we would need to know the value of INPUT - it is most certainly one of 1, 2, 4, 8, etc, denoting a single bit. So the expression $search->level & INPUT would yield nonzero (a.k.a. true) if the bit denoted by INPUT was set in $search->level. -- >O Ernest E. Vogelsinger (\) ICQ #13394035 ^ http://www.vogelsinger.at/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php