位置: 编程技术 - 正文

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

  • 税务局防范税收风险的措施
  • 老板的报销分录怎么写
  • 开农贸市场挣钱吗
  • 500以下的收据可以入账吗
  • 对公收到一分钱怎么做账
  • 非居民企业所得税税率10%
  • 通行费进项抵扣政策
  • 住宅小区共用部位有哪些
  • 掌握无形资产核算方法
  • 预计负债账务处理 固定资产
  • 委外研发费用如何开票
  • 开专票还要另外再交钱么
  • 现金不够怎么办
  • 教育费附加会计分录
  • 消费型增值税计算公式
  • 代开增值税发票沒有付款怎么做账?
  • 企业劳务外包取费的标准以及依据是什么?
  • 银行贷款受托支付受托人有风险吗
  • 金融机构在境外
  • 如何准确区分不动产租赁和仓储服务?
  • 交通费,通讯费均按照上级行标准领取
  • 会计科目按经济类型分类
  • 新个人所得税的发展现状
  • 代理进口合同如何签署
  • 耕地占用税的具体内容
  • regsrv.exe - regsrv是什么进程 有什么用
  • 出租不动产预缴增值税计算公式
  • Vue Grid Layout -️ 适用Vue.js的栅格布局系统(保姆级使用教程)
  • 外商投资企业和外资企业的区别
  • 拉姆绍在哪里
  • php get_headers
  • phpmyadmin版本
  • php xml转字符串
  • 企业清算所得税政策
  • 以摊余成本计量和以公允价值计量的区别
  • 小规模纳税人的企业所得税税率
  • vue关闭路由
  • mysql分区语句
  • 广东高速公路过路费官网
  • 勘察设计费怎么入账
  • python编程快速上手pdf百度云
  • 个体工商户属于灵活就业人员吗
  • 农业合作社需要交土地使用税吗
  • 织梦专题页模板
  • 勾稽关系怎么算
  • 技术转让和技术开发区别
  • mysql最新版怎么中文
  • 可以公账户给私人转账吗
  • 以固定资产换入库存商品
  • 出口的进项发票认证后要确认吗
  • 交增值税怎么做帐
  • 装修费没发票怎么记账
  • 根据《物业管理条例》的规定,物业服务企业
  • 公对公转账后对方拒绝开发票
  • 客户用个人账户转4s店开公司的机动车发票
  • 收到同业清算互联前置如何入账
  • 服务企业的建账方案
  • SQL Server中通过扩展存储过程实现数据库的远程备份与恢复
  • skydrive pro
  • win8系统怎么重置
  • window10预览在哪里找
  • 怎么彻底卸载visual
  • ubuntu 启动gui
  • 在基于Xen的CentOS系统VPS上配置PPTP VPN的教程
  • xp系统exiting pxe rom
  • winhelp.exe - winhelp是什么进程
  • win8系统没有wifi
  • ghost7sp1安装教程
  • 笔记本win7电源已接通未充电怎么办
  • cocos2dx4.0教程
  • js中正则表达式语法
  • android四大组件的作用
  • node-js
  • unity unite
  • javascript基础
  • jQuery 中ajax异步调用的四种方式
  • 个人限购
  • 深圳蛇口社保局在哪里
  • 中关村税务所上班时间
  • 出口货物开票税率是多少
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设