位置: 编程技术 - 正文

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

  • 个人物品出售要交哪些税
  • 季度报税是哪几个月几号申报
  • 企业所得税的纳税义务人不包括下列哪类企业
  • 留存收益的个别资本成本率计算公式
  • 固定资产变卖怎么开票
  • 无偿调入固定资产计提折旧吗
  • 小规模纳税人税率有几种
  • 企业不开票的收入会怎么样处理
  • 所得税筹划的意义
  • 展板制作费属于什么服务
  • 深圳增值税发票选择确认平台使用
  • 收到投资款怎么做会计凭证
  • 免征增值税企业进项税怎么处理
  • 农民为什么没有说理的地方
  • 职工福利费劳保用品
  • 销售之后发生销货折让收到红字发票如何做账?
  • 网上缴税后会有发票吗
  • 快递公司结算员工作量大不大
  • 已付款未收到发票怎么做分录
  • 收到原未计入应收项目的交易性金融资产的利息
  • 自收自支事业单位是什么意思
  • 需不需要计提增值税发票
  • 农产品所得税扣除比例
  • 消费税计算视频讲解
  • 企业可以申请停缴社保吗
  • 注册资本变更需要去税务局吗
  • 小规模税率还是1%吗
  • 香港公司的法人叫什么
  • 服务行业营业成本占比
  • 腾讯电脑管家怎么修复dll
  • win11专业版和家庭中文版区别
  • 残保金通过什么科目核算
  • 会计的运费怎么写分录
  • 工资薪金专项扣除项各多少
  • 年度企业所得税汇算清缴会计分录怎么做
  • win10右键失灵解决办法
  • 2021前端面试题目100及最佳答案
  • html文档怎么写
  • 房屋产权置换协议书范本
  • 企业如何申请进出口资质
  • 消费税的计算过程
  • 小规模纳税人的企业所得税税率
  • 微信自定义菜单在哪里
  • 权益法下股权投资转让
  • 新建厂房如何计提折旧费用
  • 记账凭证中的会计科目错误导致账簿错误的更正法
  • 免税农产品怎么抵扣进项税
  • python卡方分布随机数
  • 将织梦dedecms转换到wordpress
  • 弥补以前年度亏损后怎么交所得税
  • 固定资产丢失进哪个科目
  • 申报要补税怎么办
  • 公司注销其他应付款怎么冲平
  • 周转材料怎么做分录
  • 住宿费开专票怎么做账
  • 生产车间制造产品领用材料45000元,领用车间一半消耗
  • 购销供应商
  • 预付账款怎么做坏账
  • 应付暂估余额很大怎么办
  • 期末未缴税额为正是什么意思
  • YunDetectService.exe是什么进程?YunDetectService.exe禁止使用的方法
  • windows内存诊断工具检测到硬件问题怎么办
  • 如何下载苹果图书
  • mac显示所有窗口的快捷键
  • linux系统监控软件
  • xp桌面右键选项消失
  • linux中使用mkdir命令创建新的目录时
  • windows8.1界面
  • xp注册表文件在哪
  • linux device driver
  • 在linux中使用什么可以执行shell脚本
  • unity的设置在哪里
  • bat批处理命令教程
  • Unity3D游戏开发标准教程
  • js鼠标滚轮缩放
  • js函数关键字
  • android上吹一吹功能的实现代码
  • 别踩白块世界纪录视频
  • 年轻干部是什么意思
  • 哈尔滨自贸区全称
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设