bit manipulation - php synatax $b = (6 << 1); clarification -
this question has answer here:
- php operator << 5 answers
i not understand following code snippets.
$a = (5 << 0); $b = (6 << 1); echo $a|$b;
from php.net knew << operator use shift left not clear how works , uses of | operator. explanation highly appreciated. thank you
5 << 0
produces 5, since no shift done. 6 << 1
shift bits in 6 (110b) 1 left, produce 12 (1100b). multiplying 2 essentially.
the | operator bitwise or, operates on bits of 5 (0101b) , 12 (1100b) producing 13 (1101b)
Comments
Post a Comment