lay3478 Posted December 13, 2018 Share Posted December 13, 2018 I came across usage of ^= in one the password hashing codes and am trying to find what this operator means in PHP. Quote Link to comment Share on other sites More sharing options...
gw1500se Posted December 13, 2018 Share Posted December 13, 2018 Syntax error. Quote Link to comment Share on other sites More sharing options...
mac_gyver Posted December 13, 2018 Share Posted December 13, 2018 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. 1 Quote Link to comment Share on other sites More sharing options...
requinix Posted December 13, 2018 Share Posted December 13, 2018 Basically every "$x symbol= $y" means "$x = $x symbol $y". So the question is really more about what ^ means. Convenient list of operators Quote Link to comment Share on other sites More sharing options...
gw1500se Posted December 13, 2018 Share Posted December 13, 2018 Oops. Apologies. I misread the syntax. Quote Link to comment Share on other sites More sharing options...
Barand Posted December 13, 2018 Share Posted December 13, 2018 For example $a = 1010 $b = 1111 $b ^= $a // Xor $b = 0101 $b ^= $a // repeat Xor $b = 1111 // $b restored 1 1 Quote Link to comment Share on other sites More sharing options...
lay3478 Posted December 13, 2018 Author Share Posted December 13, 2018 Thanks @Barand Quote Link to comment Share on other sites More sharing options...
lay3478 Posted December 13, 2018 Author Share Posted December 13, 2018 Thanks everyone. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.