PHP manual doesn’t say that there is one, but… maybe there’s a hidden one?
Simply, I like using if‘s with symbolic operation representations, that way I’m sure that when searching through a document, I’ll always find what I’m looking for. But with xor there’s possibility that my code contains such a string/value or something. Like, method in template class – exorcize();.
You could use
!=if they’re both already booleans.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 they’re not already booleans, you’ll need to cast them.
Edit: After some experimentation with PHP’s very lax type coercion, I give you a pseudo-operator of own creation, the
==!operator!$a ==! $bis equivalent to$a xor $b.This is actually
'hello' == !0>'hello' == true>true == true>true, which is why it works asxor. This works because when PHP compares one boolean with anything else, it converts the second argument to boolean too.