位置: 编程技术 - 正文

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

  • 什么是价税分离?
  • 差旅费抵扣进项税政策201939号文件
  • 个人去税务局开普票,税率几个点
  • 印花税是按开票收入申报的吗
  • 个人银行帐户可查询多少年
  • 企业外部风险包括
  • 车辆保险怎么计算器
  • 企业在筹办期间发生的开办费计入管理费用账户
  • 升级后的百旺开票系统如何操作
  • 如何查询以前申诉进度
  • 基建拨款账务处理
  • 联营店铺收取的收入如何账务处理?
  • 净资产属于政府预算会计要素吗
  • 存货的入账价值怎么计算
  • packethsvc.exe - packethsvc是什么进程 有什么用
  • 安装win7的步骤
  • 如何备份电脑系统到另外一个硬盘
  • rapimgr.exe - rapimgr进程是什么文件.有哪些作用
  • 公司资质办理费用
  • 公司总部固定资产折旧
  • win11dev预览修复工具
  • 特殊收入应扣减可加计扣除的研发费用政策依据
  • 外贸企业出口免抵退
  • 发票开具时限是怎么规定的
  • 行政事业性收费目录
  • 目前最流行的婚纱照风格
  • 远程访问群晖nas
  • 财政资金借款给企业
  • 企业年金如何缴纳计算方法
  • php判断是否连接数据库
  • vmware vmtools
  • 差额征税的几种情况
  • 增值税专用发票和普通发票的区别
  • 增值税进项发票不够抵扣怎么办
  • 先做凭证再付款
  • 小规模申报增值税减免税申报明细表
  • 发票2种
  • Qt Port of WebKit ¶
  • sqlsever无法连接到服务器
  • 购买牵引车和挂车购车流程
  • 外资企业可以融资吗
  • 用友电子报表怎么生成
  • 过次页和承前页怎么算
  • 对公收费明细入账是手续费吗
  • 当月没有凭证还能报税吗
  • 企业购入材料收到供货单位开具的发票
  • 一般纳税人外地预缴税款怎么做分录
  • 电子承兑汇票的承兑人是谁
  • 研发收入超过研发成本
  • 个人账户发工资扣税吗
  • 事业单位私车公用如何处罚
  • 怎样计算存款利息?
  • sql 语句
  • windowssever 2003
  • 重装系统注册表会重置吗
  • 怎么停止u盘自动运行
  • FreeBSD mpd VPN服务器安装步骤
  • 重装windows764 位后后如何将apache mysql加入系统服务
  • centos查看某个端口
  • centos配置httpd
  • win1共享
  • windows10 uac关闭
  • centos7.6安装kvm
  • windows wps
  • linux mv命令的用法
  • c#在unity的作用
  • div滚动条怎么设置
  • ExtJs扩展之GroupPropertyGrid代码
  • android开源软件
  • linux curl用法
  • 收藏了很久的句子
  • [置顶]马粥街残酷史
  • es6 new set()
  • 在Debian(Raspberry Pi)树莓派上安装NodeJS的教程详解
  • android内存泄露监测
  • 发票上的税务号
  • 未按时缴纳税款是什么行为
  • 督查局工作怎么样
  • 税务师事务所牌匾
  • 新疆税务总局网站官网
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设