- var_dump: documentation ( source)
- pack: documentation ( source)
- unpack: documentation ( source)
<?php
$command = 1;
$chksum = 2;
$session_id = 3;
$reply_id = 4;
$command_string = 'test';
$buf = pack('SSSS', $command, $chksum, $session_id, $reply_id).$command_string;
$buf = unpack('C'.(8+strlen($command_string)).'c', $buf);
var_dump($buf);