How does the bitwise operator '^' work?

Posted by SpawnCxy on Stack Overflow See other posts from Stack Overflow or by SpawnCxy
Published on 2010-04-20T12:12:54Z Indexed on 2010/04/20 12:23 UTC
Read the original article Hit count: 226

Filed under:
|

I'm a little confused when I see the output of following code:

$x = "a";
$y = "b";
$x ^= $y;
$y ^= $x;
$x ^= $y;
echo $x; //got b
echo $y; //got a

And I wonder how does the operator ^ work here?Explanations with clarity would be greatly appreciated!

© Stack Overflow or respective owner

Related posts about php

Related posts about bitwise-operators