TheDocumentation Index
Fetch the complete documentation index at: https://docs.syntblaze.com/llms.txt
Use this file to discover all available pages before exploring further.
or operator in PHP is a logical disjunction operator that evaluates two operands and returns true if at least one of the operands evaluates to true, and false otherwise. It employs short-circuit evaluation, meaning the PHP engine will not evaluate the right operand if the left operand already resolves to true.
Syntax
Truth Table
The operator follows standard boolean logic for disjunction:$expr1 | $expr2 | Result |
|---|---|---|
true | true | true |
true | false | true |
false | true | true |
false | false | false |
Operator Precedence (or vs ||)
PHP provides two logical OR operators: or and ||. While they perform the exact same logical operation, they possess significantly different operator precedence.
The or operator has lower precedence than the assignment operator (=), whereas the || operator has higher precedence than the assignment operator. This structural difference dictates how expressions are bound during parsing.
or operator to evaluate before assignment, explicit grouping via parentheses is required:
Short-Circuit Evaluation Mechanics
Becauseor requires only one true operand to return true, the PHP parser optimizes execution by reading left to right. If the left operand evaluates to true, the overall expression is guaranteed to be true. Consequently, the right operand is completely ignored.
Master PHP with Deep Grasping Methodology!Learn More





