位置: 编程技术 - 正文

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

  • 未实际处置资产损失税前扣除金额的分录?
  • 印花税会计分录最新
  • 高新企业收到政府补贴怎么做账
  • 甲供材入账
  • 增值税有定额税率吗
  • 事务所和公司的专利工程师
  • 电器电子产品及配件入账
  • 个体工商户核定征收税率
  • 工厂筹建期间购房合法吗
  • 科技公司的成本如何核算
  • 新注册公司实收资本为0
  • 物流企业账务流程
  • 存货盘点科目
  • 支票取现的用途
  • 企业购入生产设备所支付的增值税
  • 怎么去税务局报账流程
  • 园林绿化工程税点
  • 税控盘抵扣政策依据
  • 关于水利工程
  • 增值税纳税申报表电子版在哪下载
  • 企业进项税和销项税抵扣政策
  • 资产负债表流动性从强到弱
  • 股东分红是看未交税吗
  • 华为p60pro上市时间是几月
  • PHP:mb_regex_set_options()的用法_mbstring函数
  • 转账凭证摘要怎么写原材料的
  • neoCapture.exe - neoCapture是什么进程 有什么用
  • PHP:ereg_replace()的用法_Regex正则函数
  • 公司向股东个人借款最新规定
  • 会计凭证出现的问题
  • 金融机构贷款利息规定
  • 我国居民企业甲在境外进行了投资
  • 提足折旧仍使用的逾龄房产是否交房产税
  • 钢铁企业成本核算表
  • 预加载的目的是什么
  • 社会保险费征缴暂行条例是谁制定
  • php去除指定字符
  • php获取文件内容的函数
  • php获取表单数据保存到mysql中
  • 确认的政府补助利得可以确认为收入吗
  • phpxdebug
  • 语音语言
  • gfortran编译命令
  • 复式记账法会计名词解释
  • 银行存款余额调节表保管期限
  • 如何查询发票领购日期
  • 不合格机器设备怎么处理
  • 含税含运费价格,运费谁出
  • 小规模纳税人免增值税的政策
  • 公司房租只有房东交吗
  • 月末结转后应交税费应交增值税一般无余额
  • 制造费用会计科目
  • 公司注销帐务怎么处理
  • 本年负数去年正数如何算同比
  • 企业认缴的资金放哪里
  • 可转换债券是什么资本
  • 研发费用占销售的比例
  • 新手会计做账怎么做账
  • 怎么设置材料
  • sql语句优化之用是什么
  • mysql 5.7.12 winx64手动安装教程
  • win7怎么用耳机听歌
  • elf.exe是什么程序
  • gnaupdaemon.exe是什么
  • win7任务栏窗口总是自动切换
  • mac局域网控制windows
  • mac屏保怎么换
  • win7电脑关机后自动开机怎么回事
  • opengl clamp
  • unity4.x升级到unity5.x材质丢失
  • javascript怎么做
  • 获取linux命令执行结果
  • js原始值有哪些
  • linux c 线程池
  • 使用SQLite数据库保存和处理数据
  • 江苏省国税电子税务局官网发票验
  • 成都市税务局公示名单公布
  • 增值税发票选择确认平台查询不到以开出的进项发票?
  • 徐州第三税务分局
  • 地税干部
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设