位置: 编程技术 - 正文

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双屏怎么切换屏幕
  • 如何在Excel中合并计算
  • 东方蝾螈怎么养吃什么
  • 发票作废之后税钱怎么退回了
  • php ftp功能
  • 经营性租赁与融资性租赁
  • 股东未实缴资本,因为经营困难借给公司钱,可以要求返还
  • 电脑麦克风没声音是什么原因
  • 短期借款帐务处理
  • vue element ui教程
  • 事业单位以固定薪资为准
  • 城建税教育费附加会计分录
  • cat 开源
  • vue父子组件如何传递数据
  • 个人出租租房交什么税
  • 固定资产提足折旧后,不论能否继续使用
  • php算法面试题有答案吗
  • 增值税普票能抵税吗
  • 海关缴款书能重开吗
  • 无形资产开发阶段的支出应当全部资本化
  • 主营业务成本的借贷方向
  • 代收代付的会计分录
  • 减免税款属于政府补助利得吗
  • 金融企业往来支出属于什么科目
  • 收到预收款开具发票如何入账
  • 股东权益和债权人
  • excel账务处理心得
  • 分期付款购入固定资产该如何做账务处理呢?
  • 未付工资挂什么科目
  • 应交销项税转出分录
  • 个体生产经营所得税
  • 税法对企业费用的限定
  • 小微企业免税如何做账
  • 哪些企业可以减免企业所得税
  • 明细分类账如何填写
  • sql存储过程什么意思
  • sql储存过程
  • mac怎样解压缩
  • ubuntu f7
  • win8系统运行在哪里
  • Windows XP用户账户控制
  • 乾坤大挪移秘籍图片
  • macpro防火墙需要打开吗
  • xp开机chkdsk
  • centos简易安装
  • 进程mmc.exe
  • win7系统禁止更新
  • win7系统搜索在哪
  • ssh登录报错
  • wp8.1升级10
  • nodejs搭建web服务器
  • 脚本被删除
  • 拥有一个属于自己的空间高中作文
  • 通过短信发送费用可能会收取运营商费用
  • 仿淘宝源码
  • js格式化输出数字
  • python遍历列表的两种方法
  • 大征期 是什么
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设