bit manipulation - php synatax $b = (6 << 1); clarification -


this question has answer here:

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

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -