desean1625/structphp 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

desean1625/structphp

Composer 安装命令:

composer require desean1625/structphp

包简介

A port of python struct module to php

README 文档

README

Python Struct Port to PHP for pack and unpack functions

Install

composer require desean1625/structphp

The module defines the following functions:

unpack(fmt, a, p) Return an array containing values unpacked from the octet array a, beginning at position p, according to the supplied format string. If there are more octets in a than required by the format string, the excess is ignored. If there are fewer octets than required, Unpack() will return undefined. If no value is supplied for the p argument, zero is assumed.

pack(fmt, values) Return an octet array containing the packed values array. If there are more values supplied than are specified in the format string, the excess is ignored. If there are fewer values supplied, Pack() will return false. If any value is of an inappropriate type, the results are undefined. calcsize(fmt) Return the number of octets required to store the given format string. calcLength(fmt) same as calcsize

    Format | C Type         |  Size (octets) | s
    -------------------------------------------------------------------
       A   | char[]         |     Length     
       x   | pad byte       |        1      
       c   | char           |        1       
       b   | signed char    |        1       
       B   | unsigned char  |        1       
       h   | signed short   |        2      
       H   | unsigned short |        2       
       i   | signed long    |        4      
       I   | unsigned long  |        4       
       l   | signed long    |        4      
       L   | unsigned long  |        4      
       s   | char[]         |     Length     
       f   | float          |        4      
       d   | double         |        8       
require "./vendor/audoload.php";
$struct = new Desean1625\Struct();

 print_r($struct->unpack("<2h", pack("v2", 10, 10)));//v	unsigned short (always 16 bit, little endian byte order)
 print_r($struct->unpack(">2h", pack("n2", 10, 10)));//n	unsigned short (always 16 bit, big endian byte order)
 print_r($struct->unpack(">2L", pack("N2", 10, 10)));//N	unsigned long (always 32 bit, big endian byte order)
 print_r($struct->unpack("<2L", pack("V2", 10, 10)));//V	unsigned long (always 32 bit, little endian byte order)

统计信息

  • 总下载量: 846
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 5
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 5
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2017-05-06

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固