The "or" operator works because PHP-Interpreter is smart enough: Since the "or" connection is true, if the first one is true, it stops executing the instruction when the first is true.
Imagine the following code (PHP):
function _true() { echo "_true"; return true; } function _false() { echo "_false"; return false; }
now you can bind function calls and see what happens in the output:
_true() or _true() or _true();
only "_true" will tell you, because the chain ends after the first one was true, the other two will never be executed.
_false() or _true() or _true();
will give "_false_true" because the first function returns false and the interpreter continues.
The same thing works with "and"
You can also do the same with "and", with the difference that the "and" chain is complete when the first "false" occurs:
_false() and _true() and _true();
will echo "_false" because the result is already completed and it can no longer be modified.
_true() and _true() and _false();
will write "_true_true_false".
Because most of all functions indicate success, returning “1” to success and at level 0 you can do things like function() or die() . But some functions (in php quite rarely) return "0" to succes and! = 0 to indicate a specific error. Then you may have to use function() and die() .