位置: 编程技术 - 正文

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

  • 资源税的计税方法自产
  • 出口退税的账怎么做
  • 增值税留抵注销时怎么办
  • 个体户经营所得税率
  • 小微企业要缴纳印花税吗
  • 食品增值税专用发票可以退税吗?
  • 哪些类型的合同无效
  • 红冲去年的收入怎么做账
  • 企业计提预提费用的会计分录如何编制?
  • 固定资产预计净残值最后怎么处理
  • 购买原材料已付款怎么记账
  • 一般纳税人怎么交税
  • 建筑工程的适用范围
  • 一般纳税人取得小规模纳税人的专票可以抵扣吗
  • 固定资产一次性计入费用的账务处理
  • 药材种植政策
  • 固定资产无偿移交怎么做账
  • 财务刻章属于什么行业
  • 与收益相关的政府补助的确认
  • 商业写字楼
  • 事业单位项目前景怎么样
  • 债券到期收回本息的会计分录
  • 华为鸿蒙harmonyos刷机
  • 空调应该计入什么科目
  • php 生成缩略图
  • 苹果充电宝怎么验真假
  • PHP:pg_cancel_query()的用法_PostgreSQL函数
  • 销售合同怎么计提折旧
  • 修改配置文件是什么意思
  • 除甲醛的净化器哪个品牌做得最好
  • 营业外收入不算收入吗
  • 会计有哪几种
  • php功能模块
  • 刷题有什么作用
  • 开源dap
  • 土地成本会计分录
  • 车船税酌定减免
  • mysql性能提升
  • 大学生创新创业平台
  • 坏账准备计入科目
  • 去年的滞纳金没有入账怎么处理
  • 公司股东退股如何对资产纳税
  • 个人报销电话费开发票是个人名还是公司名
  • 收购发票加计扣除会计分录
  • 开具发票要注意的方面是有哪些?
  • 一般纳税人是指哪些人群
  • 开诊所会计应如何做账
  • 未发生账务类交易
  • 单位收走三方协议
  • 年底盈利但有往年亏损怎么处理
  • 员工医药费属于什么费用
  • 预付款已经开了发票未到货要怎么做账
  • 固定资产一次性加速折旧
  • 企业为职工购买互助保障项目经费可以有什么开支
  • 18年水利基金税率
  • 生产成本是费用要素吗
  • 会计账本是一年一本吗
  • windows10的设置在哪里
  • linux dd 系统
  • win10怎么禁止用户安装程序
  • dos下运行安装文件
  • symsrv.dll 病毒专杀
  • cent linux
  • win102021年1月大更新
  • dev c++怎么配置环境
  • js函数详解
  • unit uniform
  • JavaScript的21条基本知识点
  • python读取数据
  • javascript的change
  • a标签的href和onclick
  • androidui布局
  • unity 内存管理
  • js 右键
  • [置顶]从lv2开始开挂的原勇者候悠闲的异世界生活
  • js的scrolltop
  • python dj
  • 北京地税税务总局官网
  • 动车票电子发票如何获取
  • 电信宽带欠费滞纳金最多减免多少?
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设