$number = 5;
$bitPosition = 2;
$bitValue = ($number & (1 << $bitPosition)) ? 1 : 0;
$number = 5;
$bitPosition = 2;
$bitValue = ($number >> $bitPosition) & 1;
$number = 5;
$bitPosition = 2;
$number |= (1 << $bitPosition);
if ($number & 1) {
echo '奇數';
} else {
echo '偶數';
}