public static function bit16(string $data, int $offset = 0, $endianness = false): int
    {
        // big-endian
        if (true === $endianness) {
            return unpack('n', $data, $offset)[1];
        }

        // little-endian
        if (false === $endianness) {
            return unpack('v', $data, $offset)[1];
        }

        // machine byte order
        if (null === $endianness) {
            return unpack('S', $data, $offset)[1];
        }
    }
public static function bit16(string $data, int $offset = 0, $endianness = false): int
    {
        // big-endian
        if (true === $endianness) {
            return unpack('n', $data, $offset)[1];
        }

        // little-endian
        if (false === $endianness) {
            return unpack('v', $data, $offset)[1];
        }

        // machine byte order
        if (null === $endianness) {
            return unpack('S', $data, $offset)[1];
        }
    }
public static function bit16 ( string $ data , int $ offset = 0 , $ endianness = false ) : int { // big-endian if ( true === $ endianness ) { return unpack ( 'n' , $ data , $ offset ) [ 1 ] ; } // little-endian if ( false === $ endianness ) { return unpack ( 'v' , $ data , $ offset ) [ 1 ] ; } // machine byte order if ( null === $ endianness ) { return unpack ( 'S' , $ data , $ offset ) [ 1 ] ; } }
Read an unsigned 16 bit integer.

@param string $data
@param int    $offset
@param mixed  $endianness

@return int
Read an unsigned 16 bit integer .