需要解释PHP中的&运算符? [重复]

This question already has an answer here:

i'm new here and i have a question that i couldn't find an answer to:

<?php 
$val1 = 25; 
$val2 = 15; 
echo ($value & $value1); // output : 9
?>

Can anyone explain step by step how this returned 9 ?

Thank you

</div>

& operator works with binary representation of a number:

25 is 00011001 15 is 00001111

00011001
       &
00001111
--------
00001001

Which is 9 in decimal.

& is an AND operator. It's sort of like &&, but applies to binary numbers.

25 = 00011001

15 = 00001111

.....& 00001001 which in binary is 9

Basically, only the bits that are 1 in both the first and second number remain 1, the rest turn to 0.