I'm using a function I found online. What does the & mean in this conditional?
if ($strength & 8) {
$consonants .= '@#$%';
}
$strength is supposed to be a number 0-8. The function is intending to use all $consonants concatenations where $strength < 8. (might explain why the function is not working).
A single &
is the bitwise operator and the double &&
is the logical. (i.e. Bits that are set in both $strength
and 8
are set in your example.) It's a lot more complicated than just saying that and it requires an understanding of how binary works.
EDIT: Check out this article for more information on Bitwise operators.
& is a bitwise operator - it's checking to see if the bits that total 8 are set. In this case, 1000
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With