位置: 编程技术 - 正文

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

  • 中型企业的标准是什么 划分标准
  • 税控盘维护费会计分录怎么写
  • 进料加工贸易流程
  • 销项税额是指
  • 水泥建材公司
  • 普通人如何交五险一金
  • 单位给员工投保
  • 大行建筑有限公司分公司
  • 小规模季度报税流程
  • 境外人员为境内企业提供劳务如何缴税
  • 土地租赁合同要公证吗
  • 控股股权转让
  • 预付账款冲减费用
  • 招待住宿费计入什么科目
  • 如何处理没有录音的人
  • 在汇兑结算方式中汇入行对流行代取的款项应先转入
  • 承接所有业务
  • 税控系统技术维护费抵扣如何填报
  • 公允价值变动损益属于损益类的
  • 嵌入式软件开发工程师
  • 记账凭证和转账凭证可以装订在一起吗
  • 收到畜禽无害化处罚通知
  • 食堂买菜怎么算
  • 免税收入和不征税收入有哪些?怎么记忆
  • 无偿赠送的原材料怎么处理
  • 初级会计实务的心得体会
  • 公司总经理报销找谁签字
  • 联想一体机如何调节屏幕亮度
  • vim diff对比
  • macbookprofacetime
  • 结转结余会计分录
  • 与取得收入无关的成语
  • 棕榈滩的读音
  • 合伙企业分配股票给合伙人
  • 智能驾驶adas概念股龙头
  • vue3.0配置代理
  • 车道线检测模型
  • nodejs官方文档
  • 查询的命令
  • 没有开发票的收入
  • 外经证预缴税款之后剩下的税款交到哪呢
  • 汇兑损益的会计处理原则
  • 企业应收账款的规模受哪些因素的影响?( )
  • 查账征收的纳税人能否简易注销
  • 年金现值系数公式记忆
  • 织梦模板官网
  • sqlserver四舍五入到整数
  • 小规模纳税人税率2023年是多少
  • SQL Sever2008r2 数据库服务各种无法启动问题的解决办法(详解)
  • 完工产品成本计算表怎么填
  • 其他应收款在借方怎么调账
  • 工资发多了可以追回吗
  • 债务利息收入
  • 进账单,其中有两个账户
  • 转让专利权的使用权
  • 小规模纳税人收到专票后如何处理
  • 股东股权转让印花税 公司承担
  • 一般纳税人拿到普票怎么处理账务
  • 记账凭证的分类标准
  • 进口货物只有报关单能入账吗
  • mysql源码编译
  • 什么是格式良好的xml文档
  • win10预览版绿屏重启解决
  • macbook 手写
  • windowsxp还能正常使用吗
  • onekey driver version是什么软件
  • elccest.exe是间谍广告程序吗 elccest进程有什么作用
  • window配置在哪
  • win10预览版21337
  • Win7安装VPN软件后无法上网是什么原因如何解决
  • windows操作大全
  • unity绘制曲线
  • cocos2dx 教程
  • 游戏开发主要学什么
  • 用jQuery.ajaxSetup实现对请求和响应数据的过滤
  • vue vue cli
  • jquery悬浮弹出提示框
  • 出口退税企业分类管理等级
  • 个人所得税追缴很快就缴清了还会被罚款吗
  • 太原市小店区电影院营业时间
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设