Jump to content
lay3478

^= means what in PHP language?

Recommended Posts

I came across usage of ^= in one the password hashing codes and am trying to find what this operator means in PHP.

Share this post


Link to post
Share on other sites

it's actual a combined assignment and bitwise Xor (exclusive or). the starting value on the left is Xor'ed with the value on the right and becomes the new value on the left.

  • Like 1

Share this post


Link to post
Share on other sites

For example

$a = 1010
$b = 1111
$b ^= $a   // Xor
$b = 0101
$b ^= $a   // repeat Xor
$b = 1111  // $b restored

 

  • Like 1
  • Great Answer 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.