CKTIS / PHP
Right shift (>>)
Discard low bits by shifting an integer to the right.
Version: PHP 8.4; repository runtime, production runtime not attested
Syntax
$value >> $operandDiscard low bits by shifting an integer to the right. The sign bit fills high positions, so shifting −3 by one position gives −2.
The right operand gives the number of bit positions. A negative shift count raises ArithmeticError. Shifting by zero positions preserves the number.
Evaluation
12 >> 2→37 >> 0→7(-3) >> 1→-2
Examples
<?php
echo json_encode(12 >> 2), PHP_EOL;
echo json_encode(7 >> 0), PHP_EOL;
echo json_encode((-3) >> 1), PHP_EOL;
Result
3 7 -2