-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuffer.php
More file actions
39 lines (31 loc) · 795 Bytes
/
buffer.php
File metadata and controls
39 lines (31 loc) · 795 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
/**
* This file is part of PHPinnacle/Buffer.
*
* (c) PHPinnacle Team <dev@phpinnacle.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use PHPinnacle\Buffer\ByteBuffer;
$buffer = new ByteBuffer;
$buffer->append('abcd');
$buffer->read(4);
$buffer->append(new ByteBuffer('zz'));
$buffer->consume(6);
$buffer->appendUint8(1);
$buffer->appendInt8(1);
$slice = $buffer->slice(2);
$slice->readUint8();
$slice->readInt8(1);
$buffer->consumeUint8();
$buffer->consumeInt8();
$buffer->appendUint16(1);
$buffer->appendInt16(1);
$shift = $buffer->shift(4);
$shift->consumeUint16();
$shift->consumeInt16();
$clone = clone $buffer;
$clone->appendUint32(1);
echo $buffer->flush();
echo (string) $clone;