Endian
Installation
shell
composer require thesis/endianRead/write in any byte order:
- In
network(big endian) byte order.
php
use Thesis\Endian;
echo Endian\Order::network->unpackInt32(
Endian\Order::network->packInt32(-200),
); // -200- In
big endianbyte order.
php
use Thesis\Endian;
echo Endian\Order::big->unpackInt8(
Endian\Order::big->packInt8(17),
); // 17- In
little endianbyte order.
php
use Thesis\Endian;
echo Endian\Order::little->unpackFloat(
Endian\Order::little->packFloat(2.2),
); // 2.2- In
native endianbyte order.
php
use Thesis\Endian;
use BcMath\Number;
echo Endian\Order::native()
->unpackInt64(
Endian\Order::native()->packInt64(new Number('9223372036854775807')),
)
->value; // 9223372036854775807Supported types:
- [x]
int8 - [x]
uint8 - [x]
int16 - [x]
uint16 - [x]
int32 - [x]
uint32 - [x]
int64 - [x]
uint64 - [x]
float - [x]
double
