Possible Duplicate:
Reference – What does this symbol mean in PHP?
When I was reading this php page, I was not sure what & is doing in $var & 1.
function odd($var)
{
// returns whether the input integer is odd
return($var & 1);
}
Is it returning a reference? I am not sure.
If you can explain it or direct me a php page, I will appreciate it.
Thanks in advance.
It’s a bitwise-AND operation. All odd numbers have LSB (least significant bit set to 1), even numbers – 0.
So it simply “ANDs” two numbers together. For example, 5. It is represented as 101 in binary. 101 & 001 = 001 => true, so it is odd.