Exemplo n.º 1
0
<?php

echo memory_get_usage();
echo "\n";
$bytearray = new ByteArray();
echo memory_get_usage();
echo "\n";
$bytearray->writeBoolean('true');
$bytearray->writeUTF("this is a good test!");
$byte = 1;
$bytearray->writeByte($byte);
$bytearray->writeUTF("this is a good test!");
echo $bytearray->readBoolean();
echo "\n";
echo $bytearray->readUTF();
echo "\n";
echo $bytearray->readByte();
echo "\n";
echo $bytearray->readUTF();
echo "\n";
$a = $bytearray->toString();
var_dump($bytearray);
$b4 = new ByteArray();
$b4->writeInt(strlen($a));
$b4->writeBytes($a);
$len = $b4->readInt();
echo "\n";
echo "read bytes:";
echo $len;
$bytes = $b4->readBytes($len);
echo "\n";