位置: 编程技术 - 正文

PHP:pack()的用法_misc函数(php pack)

编辑:rootadmin
pack

推荐整理分享PHP:pack()的用法_misc函数(php pack),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:php pack函数,php msgpack,php package,php msgpack,php pack unpack,php pack函数,php package,php pack函数,内容如对您有帮助,希望把文章链接给更多的朋友!

(PHP 4, PHP 5)

pack — Pack data into binary string

说明 string pack ( string $format [, mixed $args [, mixed $... ]] )

Pack given arguments into a binary string according to format.

The idea for this function was taken from Perl and all formatting codes work the same as in Perl. However, there are some formatting codes that are missing such as Perl&#;s "u" format code.

Note that the distinction between signed and unsigned values only affects the function unpack(), where as function pack() gives the same result for signed and unsigned format codes.

参数

format

The format string consists of format codes followed by an optional repeater argument. The repeater argument can be either an integer value or * for repeating to the end of the input data. For a, A, h, H the repeat count specifies how many characters of one data argument are taken, for @ it is the absolute position where to put the next data, for everything else the repeat count specifies how many data arguments are consumed and packed into the resulting binary string.

Currently implemented formats are: pack() format characters Code Description a NUL-padded string A SPACE-padded string h Hex string, low nibble first H Hex string, high nibble first csigned char C unsigned char s signed short (always bit, machine byte order) S unsigned short (always bit, machine byte order) n unsigned short (always bit, big endian byte order) v unsigned short (always bit, little endian byte order) i signed integer (machine dependent size and byte order) I unsigned integer (machine dependent size and byte order) l signed long (always bit, machine byte order) L unsigned long (always bit, machine byte order) N unsigned long (always bit, big endian byte order) V unsigned long (always bit, little endian byte order) f float (machine dependent size and representation) d double (machine dependent size and representation) x NUL byte X Back up one byte Z NUL-padded string (new in PHP 5.5) @ NUL-fill to absolute position

args PHP:pack()的用法_misc函数(php pack)

返回值

Returns a binary string containing data.

更新日志

版本 说明 5.5.0 The "Z" code was added with equivalent functionality to "a" for Perl compatibility.

范例

Example #1 pack() example

<?php$binarydata=pack("nvc*",0x,0x,,);?>

The resulting binary string will be 6 bytes long and contain the byte sequence 0x, 0x, 0x, 0x, 0x, 0x.

注释 Caution

Note that PHP internally stores integer values as signed values of a machine-dependent size (C type long). Integer literals and operations that yield numbers outside the bounds of the integer type will be stored as float. When packing these floats as integers, they are first cast into the integer type. This may or may not result in the desired byte pattern.

The most relevant case is when packing unsigned numbers that would be representable with the integer type if it were unsigned. In systems where the integer type has a -bit size, the cast usually results in the same byte pattern as if the integer were unsigned (although this relies on implementation-defined unsigned to signed conversions, as per the C standard). In systems where the integer type has -bit size, the float most likely does not have a mantissa large enough to hold the value without loss of precision. If those systems also have a native -bit C int type (most UNIX-like systems don&#;t), the only way to use the I pack format in the upper range is to create integer negative values with the same byte representation as the desired unsigned value.

参见

unpack() - Unpack data from binary string

PHP:highlight_file()的用法_misc函数 highlight_file(PHP4,PHP5)highlight_file语法高亮一个文件说明mixedhighlight_file(string$filename[,bool$return=false])使用PHP内置的语法高亮器所定义的颜色,打印输出或者返

PHP:eval()的用法_misc函数 eval(PHP4,PHP5)eval把字符串作为PHP代码执行说明mixedeval(string$code)把字符串code作为PHP代码执行。CautionTheeval()languageconstructisverydangerousbecauseitallowsexecutionofarbitr

PHP:ignore_user_abort()的用法_misc函数 ignore_user_abort(PHP4,PHP5)ignore_user_abort设置客户端断开连接时是否中断脚本的执行说明intignore_user_abort([string$value])设置客户端断开连接时是否中断脚本的执

标签: php pack

本文链接地址:https://www.jiuchutong.com/biancheng/280632.html 转载请保留说明!

上一篇:PHP:php_check_syntax()的用法_misc函数

下一篇:PHP:highlight_file()的用法_misc函数

  • 在外地预缴的印花税如何扣除
  • 汇算清缴补交所得税怎么做凭证
  • 电子税务局如何变更财务负责人
  • 增值税专用发票可以开电子发票吗
  • 二级分支机构不具有主体生产经营职能
  • 免税农产品包括烟叶吗
  • 劳务成本科目
  • 核定征收可以改查账征收吗
  • 车间报销办公费计入什么科目
  • 进项税额抵减欠税后附加税可以抵减吗
  • 发票冲销后还能用吗
  • 理财收益高的产品
  • 小规模纳税人附加税优惠政策2023
  • 房地产土地抵扣
  • 企业优惠条件
  • 来料加工原材料计入什么科目
  • win10系统如何在游戏中禁用输入法
  • 电脑玩网络游戏一小时多少流量
  • 苹果14如何强制关机重启
  • 为什么系统弹出登录此网络
  • Win11文件夹怎么加密设置密码
  • 政府补助开票怎么申报增值税
  • PHP:pg_get_result()的用法_PostgreSQL函数
  • 其他存货包括哪些内容
  • webssh github
  • php reference
  • 哪些情况即使取消核酸
  • 没进项可以开专票吗
  • thinkphp ide
  • 税务登记投资总额和注册资本一样吗
  • 红字增值税发票怎么开具图解
  • webpack性能优化 加载
  • 印花税跨年度缴纳有滞纳金吗
  • 在vue3项目中使用vue2
  • 购进原材料款项未付应编制什么凭证
  • 贷款和应收款项属于金融资产的哪类
  • 发票上多盖了一个发票章
  • 企业用车年检需要什么资料
  • mongo聚合查询效率问题
  • 织梦logo
  • 怎么导出银行去银行流水
  • 货物样品出口
  • CentOS 7下MySQL服务启动失败的快速解决方法
  • c#窗体类属性和方法
  • 房地产企业所得税管理办法
  • 结转本年利润要算期初余额吗
  • 进项税额不允许抵扣
  • 项目投标代理服务方案
  • 病假补贴需要什么手续
  • 项目前期的研发费用
  • 连锁药店成本会计
  • 开票未收到款会计分录
  • 固定资产清理贷方余额是什么意思
  • 哪些可以做进项税
  • 应付账款用什么方法清查
  • sql合并多条记录某一个字段
  • 怎么提高windows7性能
  • windows active directory功能
  • centos配置http
  • 清除桌面应用软件
  • 进程出现很多regsvr32
  • 远程桌面的文件怎么无法复制到本地桌面
  • linux系统中命令什么大小写
  • 安装网络设备
  • win10wifi总是掉线
  • win7关闭文件夹和内容一起显示
  • linux安装与部署
  • linux find命令的使用
  • 详细谈谈哲学的基本问题
  • div+css布局是什么
  • javascript如何输出变量
  • shell 比较大小
  • Python实现定时任务
  • python编写下载器
  • 百度定位服务平台
  • 2020年残保金申报截止到什么时间
  • 税收优惠政策有哪些企业
  • 铜进口量2019
  • 大连市国家税务网
  • 乡村振兴与文化遗产保护研究
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

    网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

    友情链接: 武汉网站建设