3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $a = 10000; $b = 11111; $c = $a & $b; $r = $a ^ $b; var_dump(decbin($a), decbin($b), decbin($c), decbin($r), '---'); while ($c) { $shift = $c << 1; $c = $r & $shift; $r ^= $shift; var_dump(decbin($shift), decbin($c), decbin($r), '---'); } var_dump($r);
based on rhUud
Output for 4.3.0 - 7.2.0
string(14) "10011100010000" string(14) "10101101100111" string(14) "10001100000000" string(12) "110001110111" string(3) "---" string(15) "100011000000000" string(11) "10000000000" string(15) "100101001110111" string(3) "---" string(12) "100000000000" string(12) "100000000000" string(15) "100001001110111" string(3) "---" string(13) "1000000000000" string(1) "0" string(15) "101001001110111" string(3) "---" int(21111)