Function __global->cms_unpack_to_uinteger

Definitions

sources/global3.php

  • Unpack some bytes to an integer, so we can do some bitwise arithmetic on them.Assumes unsigned, unless you request 4 bytes.
  • Visibility: public
  • Is abstract?: No
  • Is static?: No
  • Is final?: No
  • Returns: int

Parameters

Name Type Passed by reference? Variadic? Default Set Range Description
$str string No No required parameter N/A N/A Input string
$bytes ?integer No No Null 1 2 4 N/A How many bytes to read (null: as many as there are in $str)
$little_endian boolean No No False N/A N/A Whether to use little endian (Intel order) as opposed to big endian (network/natural order)

Returns

  • Read integer
  • Type: integer
  • Set: N/A
  • Range: N/A

Preview

Code (PHP)

/**
 * Unpack some bytes to an integer, so we can do some bitwise arithmetic on them.Assumes unsigned, unless you request 4 bytes.
 *
 * @param  string $str Input string
 * @param  ?integer $bytes How many bytes to read (null: as many as there are in $str)
 * @set 1 2 4
 * @param  boolean $little_endian Whether to use little endian (Intel order) as opposed to big endian (network/natural order)
 * @return integer Read integer
 */

function cms_unpack_to_uinteger(string $str, ?int $bytes = null, bool $little_endian = false) : int