位置: 编程技术 - 正文

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函数

  • 实收资本增加如何计算
  • u8反记账操作步骤
  • 销售货物和劳务的税率
  • 半成品原材料报废会计处理怎么做?
  • 研发支出转入管理费用摘要
  • 装修未付款的会计分录
  • 我国进口货物交税如何计算? 
  • 作废的发票怎么处理
  • 滞留票的进项税能抵扣吗
  • 税种认定登记流程
  • 开票资料填写
  • 增值税发票查询
  • 企业如何做好税务管理工作
  • 会议案例分析题及答案
  • 税收返还会计处理
  • 固定资产加速折旧最新政策2023
  • 暂停水电
  • 税控设备抵减如何填写报表
  • 烟丝消费税组成计税价格
  • 库存商品转在建工程摘要怎么写
  • 收取拆迁补偿费会计分录
  • 企业支付方式有几种
  • 六税两费减半会延期吗
  • 联想笔记本bios密码忘记了
  • linux系统配置ip地址命令
  • 发出商品与库存商品的区别
  • 金融服务的手续费要交税吗
  • 公司购买电脑流程怎么做
  • window的hosts文件
  • PHP:Memcached::prependByKey()的用法_Memcached类
  • 收到专利补助费的会计处理
  • 内部审计范围有哪些
  • 补缴房产税土地使用税怎么算
  • 利得的具体分类
  • 试用期人员工资财务记账
  • 酒店的押金怎么做账
  • php转换成html
  • 长期股权投资顺逆流交易的损益调整
  • cqi映射表
  • php代码生成
  • 浅谈php中静态方法的应用
  • 高德地图的2种导航方式
  • libev & libevent简介 IntelIOT 博客园
  • 待摊费用和预提费用属于什么账户
  • 进项税额转出可以为负数吗
  • 帝国cms导入模板后怎样调用
  • 帝国cms自定义列表
  • 开票软件怎样
  • 出售其他债权投资产生的收益为什么计入留存收益
  • 个体户开出的发票没跟对方说自己冲红了怎么办
  • 微信红包是否缴纳个税
  • PostgreSQL中的OID和XID 说明
  • 合同可以盖财务章子吗
  • 冲销以前年度多提税金
  • 帮别人注册医疗器械法人有风险吗
  • 工程款项目的发包人是谁
  • 建筑施工企业劳务费怎么入成本
  • 水利建设基金筹集和使用管理办法
  • 母公司及子公司增资
  • 商标无形资产摊销计入什么科目
  • 营业外支出增加说明了什么
  • 建账选用什么会计制度
  • 删除sql server2019
  • windowsserver2016安装完成后怎么是命令模式
  • iis怎么用
  • 不能在windows7里进行设置的网络位置是
  • win8删除所有文件
  • 电脑ios怎么安装
  • centos重新安装命令
  • windows10出现飞行模式怎么办
  • nb3是什么文件
  • javascript到c
  • ai人工智能python
  • 背包设备
  • javascript入门教程
  • js判断时间差
  • javascript基于什么的语言
  • 广东电子税务局官网登录入口
  • 郑州市国家税务局地址在哪里
  • 发票挂失费用
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设