位置: 编程技术 - 正文

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

  • 进口商品需要缴纳哪些税
  • 增值税是如何计提的
  • 小规模纳税人费用票怎么做账
  • 在建工程当中哪些是资产
  • 固定资产清理增加记哪一方
  • 境外企业分红怎么交税
  • 甲供材料工程如何办理结算
  • 营改增房租增值税税率
  • 建筑分包项目有哪些内容
  • 自己公司开发票有什么好处
  • 个体工商户允许哪些经营范围
  • 成本费用跨年度怎么计算
  • 应付账款核销法律规定
  • 对外捐赠资产时应计入什么科目
  • 个人股权转让印花税在哪里申报
  • 出口转内销的销项税怎么计算
  • 残值收入的会计处理
  • 其他权益工具投资属于什么科目
  • 在Win10系统中卸载最近更新的补丁并重启电脑
  • macqq截图快捷键 保存
  • 在Win7中,鼠标非最大化
  • 商业承兑汇票承兑人可以是银行吗
  • windows 7如何
  • 企业间实物交易是指
  • 税控设备购买
  • thinkphp操作数据库
  • 购买低值易耗品现金流量计入
  • 增值税发票开红字发票后账务处理?
  • 深入解析windows第7版卷2
  • 预付装修费的会计处理分录
  • composer环境变量
  • 租出固定资产的处理步骤
  • vue怎么打断点
  • 数学建模心态崩了
  • php二分查找算法两种方法
  • linuxless命令查看文件
  • 小规模固定资产处置税率
  • 企业所得税不得核定征收行业
  • 设备安装工程施工及验收规范
  • 非独立核算与独立核算
  • 员工餐费补助交个人所得税吗
  • 上月结余金额是什么的
  • 物业公司收取的电费怎么确认收入
  • 平均股东权益在哪里看
  • 进出口货物收发货人报关注册登记证书
  • 政府补助怎么判断总额法还是净额法
  • 暂估和冲暂估分录
  • 未确认融资费用账务处理
  • 律师事务所收取费用有标准吗
  • 采购材料未付款填什么凭证
  • 股东撤资后需要承担责任
  • 普通进项发票怎么做分录
  • 因质量问题对方直接扣款也不开票
  • 公司增资怎么处理
  • 小型微利企业所得税100到300
  • 总分类账户和明细分类账户平行登记的要点包括
  • 会计计量属性是什么意思
  • sqlserver 断开数据库连接
  • 数据库复制数据sql语句
  • iis如何重新配置
  • linux虚拟机基本操作
  • linux命令放在哪个路径
  • 富士通FUJITSU笔记本电脑开机进入BIOS的方法(F2)
  • 安装程序不运行怎么回事
  • mac的mail登不上
  • win10自带绘画
  • linux里面怎么截屏
  • win7旗舰版系统激活码
  • vc6.0安装教程win8
  • win8wifi设置在哪
  • 把下一行的数字去掉
  • js实现的简单鼠标代码
  • 很全面的成语
  • python函数判断质数
  • python编码有哪些规范
  • 增值税纳税申报时间
  • 运城取暖费网上怎么交
  • 会议服务费属于什么类别
  • 资源税是地方税吗
  • 北京国税查询发票真伪查询系统
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设