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.
| operator in PHP is the bitwise inclusive OR operator. It evaluates the binary representations of two operands and performs a logical OR operation on each corresponding pair of bits. If a bit is 1 in the left operand, the right operand, or both, the corresponding bit in the result is set to 1. The result bit is 0 only if both corresponding operand bits are 0.
Truth Table
| Bit A | Bit B | Result (A | B) |
| :---: | :---: | :---: |
| 0 | 0 | 0 |
| 0 | 1 | 1 |
| 1 | 0 | 1 |
| 1 | 1 | 1 |
Integer Evaluation
When operating on integers, the engine aligns the binary sequences of both numbers and evaluates them bit-by-bit.String Evaluation
If both operands are strings, PHP performs the bitwise OR operation byte-by-byte, evaluating the underlying ASCII/byte values of the characters.\x00) to match the length of the longer string. Because a bitwise OR operation between any byte and a null byte (0000 0000) results in the original byte, the remaining trailing bytes of the longer string are appended to the result unmodified.
Type Coercion Rules
The| operator enforces specific type juggling behaviors depending on the operands provided:
- Float to Integer: If an operand is a floating-point number, PHP truncates the fractional part and casts it to an integer before performing the bitwise operation.
- Mixed Types (String and Int): The byte-by-byte string evaluation is strictly reserved for when both operands are strings. If one operand is a string and the other is an integer (or float), the string must be a well-formed numeric string, which PHP will cast to an integer prior to evaluation. As of PHP 8.0, if the string is non-numeric, applying the
|operator throws aTypeErrorrather than silently casting the string to0.
Master PHP with Deep Grasping Methodology!Learn More





