функция
read_big_endian()
Проверено на WordPress 6.9, обновлено Источник: WordPress Developer Resources.
Сигнатура
read_big_endian( $input, int $num_bytes ): int
Описание
Читает беззнаковое целое число, начиная со старших битов.
Параметры
$num_bytes
int
обязательный
Количество разобранных байтов.
Возвращаемое значение
int
Исходный код
wp-includes/class-avif-info.php:42
function read_big_endian( $input, $num_bytes ) {
if ( $num_bytes == 1 ) {
return unpack( 'C', $input ) [1];
} else if ( $num_bytes == 2 ) {
return unpack( 'n', $input ) [1];
} else if ( $num_bytes == 3 ) {
$bytes = unpack( 'C3', $input );
return ( $bytes[1] << 16 ) | ( $bytes[2] << 8 ) | $bytes[3];
} else { // $num_bytes is 4
// This might fail to read unsigned values >= 2^31 on 32-bit systems.
// See https://www.php.net/manual/en/function.unpack.php#106041
return unpack( 'N', $input ) [1];
}
}

