# Weak logic operators

- Thread: https://externals.io/message/73501
- Original archive: https://news-web.php.net/php.internals/73501
- Started by Robert Stoll on 2014-04-01T13:24:33+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #73501 — Robert Stoll — 2014-04-01T13:24:33+00:00

URL: https://externals.io/message/73501#73501

Heya,

I wrote my question already on the general list but got no answer. Maybe someone on this list can help me out.
I was wondering for what reason PHP has weak logic operators. So far I have only used the weak logic operator 'or' in
the following situation:

foo() or die("nooo");

And it is quite a long time ago I have used it the last time. You could also write the following instead:

if(!foo()){
  die("noooo");
}

I am aware of that one can use 'or' and 'and' as substitute for || and && if using brackets in addition:

$a = ( foo() and bar() );

But I do not really see the benefit of writing it this ways. 
I think the weak logic operators just add more complexity to the language and hence decrease maintenance. Moreover they
are a source of confusion (should I use 'or' or || etc.). The situation for the operator 'xor' is even worse than for
'or' and 'and' in my opinion, since it has no short-circuit and one could use ^ instead of xor:

$a = ( foo() xor bar() );

Could be written as follows:
$b = foo() ^ bar();

So I am curious, are there other use cases out there that justify the existence of those operators?

Cheers,
Robert
