You could use !=
if they're both already booleans.
if (true != false) // xor
...
Of course, this has the same issue with getting false positives in your search results, so perhaps you can adopt a personal convention (at the risk of confusing your co-workers) of using the other PHP not-equal operator:
if (true <> false) // xor
...
If they're not already booleans, you'll need to cast them.
if (!$a <> !$b) // xor
...
Edit: After some experimentation with PHP's very lax type coercion, I give you a pseudo-operator of own creation, the
==!
operator!
$a ==! $b
is equivalent to
$a xor $b
.
if ('hello' ==! 0) // equivalent to ('hello' xor 0)
...
This is actually 'hello' == !0
> 'hello' == true
> true == true
> true
, which is why it works as xor
. This works because when PHP compares one boolean with anything else, it converts the second argument to boolean too.