MadelineProto/vendor/danog/phpstruct
danogentili 0be0bf090f Update
2016-07-15 15:42:49 +02:00
..
tests/danog/PHP Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
.gitignore Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
.styleci.yml Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
.travis.yml Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
composer.json Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
example.php Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
LICENSE Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00
README.md Fix syntax mistakes, added vendor dir. 2016-07-15 13:10:38 +02:00

PHPStruct class

Build Status Codacy Badge Packagist Packagist HHVM StyleCI

Licensed under MIT.

PHP implementation of Python's struct module.

This library was created to help me develop a client for the mtproto protocol.

The functions and the formats are exactly the ones used in python's struct (https://docs.python.org/3/library/struct.html)

For now custom byte size may not work properly on certain machines for the i, I, f and d formats.

Installation

Install using composer:

composer require danog/phpstruct

Usage

require('vendor/autoload.php');
$struct = new \danog\PHP\Struct();
$pack = $struct->pack("2cxi", "ab", 44);
$unpack = $struct->unpack("2cxi", $pack);
var_dump($unpack);
$count = $struct->calcsize("2cxi");

This library can also be used statically:

require('vendor/autoload.php');
$pack = \danog\PHP\Struct::pack("2cxi", "ab", 44);
$unpack = \danog\PHP\Struct::unpack("2cxi", $pack);
var_dump($unpack);
$count = \danog\PHP\Struct::calcsize("2cxi");

Daniil Gentili