Logical tricks in PHP
Do you know, how 'and' and 'or' operators works?
Probably yes. (And probably you know, what is the difference between 'and' and '&&')
What's tricky here?
The trick is: 'and' returns true when both operands are true. If the first operand is false, operator returns false immediately.
So, we can use it instead of 'if':
it works. Really.
Absolutely the same with 'or': it returns true immediately if the first operand is true (so second will not be calculated)
I bet everyone seen the following code:
When I first seen this I was thinking - what an interesting language, this looks like simple English...
Now I know what's the trick. And you too.