CKTIS / PHP
Bitwise AND (&)
Extract flags shared by two masks.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$value & $operandExtract flags shared by two masks. Comparing the result with the required mask tests whether every required flag is present.
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 both corresponding input bits are 1.
Evaluation
12 & 10→812 & 0→07 & 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
8 0 7