I am not clearly understand about the following code snippets.
$a = (5 << 0);
$b = (6 << 1);
echo $a|$b;
From php.net i knew that << operator use for shift left but not clear how it works and what is the uses of | operator. Any explanation is highly appreciated. Thank you
5 << 0
produces just 5, since no shift is done.6 << 1
will shift the bits in 6 (110b) one to the left, which will produce 12 (1100b). So it is multiplying by two essentially.The | operator is bitwise or, which operates on the bits of 5 (0101b) and 12 (1100b) producing 13 (1101b)