本帖最后由 wsysam 于 2012-08-27 12:22:42 编辑

解决方案 »

  1.   

    首先,按照posix标准
    1字节     uint8_t
    2字节     uint16_t
    4字节     uint32_t其次 uint 是无符号整型数(unsigned int)于是可用 unpack 解包
    设 $str 为接收到的串
    $d = unpack('A4Magic/CVersion/CCommand/CClientOS/lStatus/lLength', $str);
    $d['Magic'] = unpack('C*', $d['Magic']);print_r($d);