Bitwise AND operator in PHP (&)

July 28, 2022  ‐ 1 min read

For the bitwise AND operator in PHP the ampersand sign is used (&). Together with the other bitwise operators in PHP, the AND operator allows us to perform logical operators.

The AND operator only results in true if both operands are true, or 1 instead of 0.

The truth table of the AND operator in PHP looks as follows:

<?php

echo true  & true   # => true
echo true  & false  # => false
echo false & true   # => false
echo false & false  # => false