位置: 编程技术 - 正文

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

  • 合同中增值税税率怎么描述
  • 药酒消费税计税依据
  • 公司间借款利息增值税进项能否抵扣
  • 小规模纳税人个税是月报还是季报
  • 出货一般要多久
  • 境内公司代付境外货款
  • 金蝶专业版利润表本年累计公式
  • 私人企业利润怎么分配?
  • 合同租金总收入怎么填
  • 无形资产的摊销,可摊销的标准是什么?
  • 利息收入红冲怎么做
  • 零售商品收入会计分录
  • 原材料的运输费怎么做会计分录
  • 研发物资
  • 汉字防伪企业是哪家
  • 企业清算企业所得税税率
  • 增值税专用发票有效期是多长时间
  • 固定资产加速折旧方法
  • 进项税和销项税抵扣的会计分录
  • 电子账册需要缴纳印花税的规定是怎么说?
  • 外账缺成本费用怎么处理
  • 小规模企业记账软件哪个好
  • 生产车间的费用会计分录
  • printnow.exe - printnow是什么进程 有什么作用
  • 电脑怎么搜索文档
  • 企业所得税计算方法公式
  • 怎样改善现金流量比率
  • 新西兰萨摩亚人
  • 利用php实现开心麻花
  • 在建工程计提减值准备计入什么科目
  • 长期借款科目核算方法
  • css去掉项目符号
  • 减税性质代码及名称农业
  • 跨年度退货的账务处理
  • phpbug
  • 基建账如何并入会计科目
  • 大前端最新
  • lnewusers命令 创建用户账号
  • 支付国外佣金需要开票吗
  • 开具增值税专用发票是什么意思
  • 国外商贸公司
  • 借贷公司借钱给别的公司需要开什么会
  • phpcms是什么框架
  • 公司法人和经理的区别
  • 记帐时借方是什么意思
  • 让税务局代开的发票直接交纳的税金如何做会计分录?
  • 应付利息的账务处理
  • 营业外收入如何纳税
  • 零余额账户银行回单
  • 收购分公司有什么要求
  • 差旅费是什么支出类型
  • 电梯在固定资产里属于什么设备类别
  • 会计凭证要保存多少年企业注销
  • 银行存款日记账电子表格模板
  • mysql命令导入
  • win8更新win8.1
  • 微软宣布9月30日停止在俄罗斯服务
  • xp 指定的域不存在,或无法联系
  • linux 显示
  • WIN7系统怎么删除UG其它版本的许可证
  • macbook怎么剪视频软件
  • xp电脑开机自检怎么取消
  • 升级win10后悔了
  • gho文件过大
  • 跑跑3s是谁
  • 彻底弄懂js中的this指向
  • js计数排序
  • Node.js中的什么模块是用于处理文件和目录的
  • 好用的shell终端
  • OnApplicationFocus
  • android图片透明度怎么设置
  • 迄今最好的Http请求框架
  • web docs
  • js当前时间格式化
  • 税务副科级选拔
  • 设计服务属于什么税目
  • 河北电子税务局网上登录
  • 湖北省电子税务局操作指南
  • 国家税务局关于印发的通知
  • 城镇土地使用税优惠政策
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设