CKTIS / PHP
Bitwise OR (|)
Combine two flag sets while retaining every set bit.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$value | $operandCombine two flag sets while retaining every set bit. Including the same flag again leaves the result unchanged.
A mask works on individual bits of integers. When both operands are strings, PHP operates on their bytes and returns a string. A result bit is 1 when at least one corresponding input bit is 1.
Evaluation
12 | 10→1412 | 0→127 | 7→7
Examples
<?php
echo json_encode(12 | 10), PHP_EOL;
echo json_encode(12 | 0), PHP_EOL;
echo json_encode(7 | 7), PHP_EOL;
Result
14 12 7