Well, I know | would means 'OR' in php; however, when I was trying to make it work with number, things go weired.
You may want to try the code below:
<?php
$i = 101;
$i |= 7;
echo $i; // output: 103 ?! why?!
?>
Well, I know | would means 'OR' in php; however, when I was trying to make it work with number, things go weired.
You may want to try the code below:
<?php
$i = 101;
$i |= 7;
echo $i; // output: 103 ?! why?!
?>
It would convert into binary when you pass |
to values. Please refer for more What Does Using A Single Pipe '|' In A Function Argument Do?
Explanation:
Decimal Binary
101 1100101
7 111
OR (|) operation in these values:
64 32 16 8 4 2 1 = Value
1 1 0 0 1 0 1 = 101
1 1 1 = 7
-------------------------------
1 1 0 0 1 1 1 = 103
Its a bitwise OR
operator. Explanation:
Binary of 101
is: 01100101
and place values are: 64+32+4+1
Binary of 7
is: 111
and place values are: 4+2+1
Both values sets together will be: 64+32+4+2+1 = 103