phpbuffer用于php对数据进行二进制序列化并与其他语言交互。并同时提供网络协议的封装。
比如二进制序列化:
require ‘class/BigEndianBytesBuffer.php’; class request { public $width = 5; public $height = 6; private $buffer; public function __construct() {
$this->buffer = new BigEndianBytesBuffer ( ); } public function tobytes() { $this->buffer->clear (); $this->buffer->writeInt ( $this->width ); $this->buffer->writeInt ( $this->height ); return $this->buffer; } }