Table of contents
Namespace: Com\Tecnick\File
Read only: Yes
File: Byte.php line 40
Big-endian byte-level reads from a binary string
The 32-bit readers (getULong(), getLong(), getFixed()) assume a 64-bit PHP build: on a 32-bit build the intermediate left shift overflows the platform integer.
Tags
- since: 2015-07-28
- category: Library
- author: Nicola Asuni info@tecnick.com
- copyright: 2015-2026 Nicola Asuni - Tecnick.com LTD
- license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
- link: https://github.com/tecnickcom/tc-lib-file
Methods
__construct()
File: Byte.php line 52
public __construct(string $str) : mixed
Parameters
- $str : string: String (binary) from where to extract values
getByte()
File: Byte.php line 93
public getByte(int $offset) : int
Parameters
- $offset : int: Point from where to read the data.
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
8 bit value
getFixed()
File: Byte.php line 245
public getFixed(int $offset) : float
A fixed-point 16.16 number is the signed int16 integer part plus the unsigned 16-bit fractional part divided by 65536 = (1 « 16).
Parameters
- $offset : int: Point from where to read the data.
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
float —
Fixed-point value
getFWord()
File: Byte.php line 171
public getFWord(int $offset) : int
Alias for getShort().
Parameters
- $offset : int: Point from where to read the data.
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
16 bit value
getLength()
File: Byte.php line 64
public getLength() : int
Return values
int
getLong()
File: Byte.php line 216
public getLong(int $offset) : int
Parameters
- $offset : int: Point from where to read the data
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
32 bit value
getShort()
File: Byte.php line 129
public getShort(int $offset) : int
Parameters
- $offset : int: Point from where to read the data.
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
16 bit value
getUFWord()
File: Byte.php line 152
public getUFWord(int $offset) : int
Alias for getUShort().
Parameters
- $offset : int: Point from where to read the data.
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
16 bit value
getULong()
File: Byte.php line 193
public getULong(int $offset) : int
Parameters
- $offset : int: Point from where to read the data
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
32 bit value
getUShort()
File: Byte.php line 111
public getUShort(int $offset) : int
Parameters
- $offset : int: Point from where to read the data
Tags
- throws: RangeException if the requested read is out of bounds.
Return values
int —
16 bit value