The ‘^’ is a bitwise operator in PHP, i.e XOR (exclusive OR) bitwise operator, that is used to display the ASCII values of variables in question. For example − For evert bit in the value, the ^ operator checks if that bit is the same in the other value too. If the values are same, 0 is produced as an output, otherwise 1 is shown as output. Below is an example illustrating the same −
Example
<?php $x = "a"; $y = "b"; $x ^= $y; $y ^= $x; $x ^= $y; echo $x; echo "\n"; echo $y; ?>
Output
b a
Different variables are assigned character values and the ‘^’ operator is used to perform XOR on the two variables. Relevant output is displayed on the console.