I saw this operator |=
in another question and I wondered what it does. It looks like this:
$result |= (ord($safe[$i % $safeLen]) ^ ord($user[$i]));
I saw this operator |=
in another question and I wondered what it does. It looks like this:
$result |= (ord($safe[$i % $safeLen]) ^ ord($user[$i]));
It's just a combined operator: assignment(=
) and a OR operator(|
). It's the same as:
$result = $result | (ord($safe[$i % $safeLen]) ^ ord($user[$i]));
Bitwise OR(inclusive) operator |
:
a | b | result
---------------------
0 | 0 | 0
1 | 0 | 1
0 | 1 | 1
1 | 1 | 1
Bitwise XOR(exclusive) operator ^
:
a | b | result
---------------------
0 | 0 | 0
1 | 0 | 1
0 | 1 | 1
1 | 1 | 0