Welcome to my series on every PHP keyword and its usage. Today’s item: xor.

The xor (exclusive or) operator is a logical operator that will result in true if only one of its operands are true. If neither is true, or both of them are true, the result of the expression is false.

Example

1
2
3
4
5
6
7
8
<?php
// False
$a = false xor false;
$b = true xor true;

// True
$c = false xor true;
$d = true xor false;