What you're doing there is utilizing the bitwise 'xor' operator. It's a little bit in depth to explain this operation in detail so we'll go with "it just works"... sort of. Since we're only working with one bit (0 or 1) the expression works something like:
So, really we're making FALSE into (int) 1, or TRUE into (int) 0 rather than strictly converting between TRUE/FALSE. An alternative (which actually preserves boolean type) would be to go along the lines of:
As mentioned above, it keeps the boolean type rather than giving integer results and is also, for me at least, more logical (pardon the pun) in that we're saying (if $myVar is originally true) "$myVar equals not $myVar" => "$myVar equals not true" => "$myVar equals false".
The Following User Says Thank You to Salathe For This Useful Post: