位置: 编程技术 - 正文

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

  • 个人所得税专项附加扣除子女教育
  • 小微企业企业所得税计算公式
  • 个人所得税本期收入是扣完保险吗
  • 农产品计算抵扣的税务政策
  • 营改增前甲供材料如何纳税
  • 增值税可以抵扣企业所得税吗
  • 医疗器械销售初次拜访话术
  • 作废的发票还需要装订在凭证里吗
  • 国家税务总局关于取消增值税扣税凭证
  • 案例讲解:当年度未及时取得有效凭证的相关成本、费用涉税处理
  • 药用植物所
  • 公司开出的发票
  • 车间扫帚存放架子
  • 退税发票勾选后开红冲发票怎么申报
  • 补提以前年度税费应该计入
  • 应付政府补贴款名词解释
  • 家具属于固定资产什么类别
  • 上年度少计提的税金及附加
  • 公司银行贷款能贷多少
  • Windows11预览体验
  • php处理图片需要什么扩展
  • PHP:apache_reset_timeout()的用法_Apache函数
  • php调用图片
  • 调制解调器的作用包括
  • 存货盘盈盘亏影响当期利润吗
  • 淘宝api接口
  • 软件开发企业进项税额抵扣
  • zen+框架
  • php curl_init
  • 钢管扣件租赁公司社会实践报告怎么写范文
  • django pypi
  • 存货盘亏的账务处理进项税额转出
  • vue监听页面加载完毕
  • 中标费用由哪方出
  • 应交税费-应交增值税
  • 铁路运输企业受托代征 印花税
  • 当月注销外管证个税账户也会注销吗
  • 实例理解SQL中truncate和delete的区别
  • windows11/windows10专业清理的系统工具Duplicate Cleaner5.0.13中文破解免费下载
  • 交易性金融资产的账务处理
  • sql查询树状数据
  • 小规模增值税纳税人税率
  • 兼职收入用缴纳增值税吗
  • 普通发票开具的管理是?
  • 预收账款的账务处理
  • 补缴税款需要交滞纳金吗
  • 商品周转率公式
  • 房地产企业收到政府土地补偿款如何入账
  • 未确认收入的会计分录
  • 费用科目可以在借方吗
  • 专项应付款如何冲减
  • 其他货币资金微信和支付宝的管理
  • 工程开票金额大写怎么写
  • 暂估怎么冲回
  • 物业服务企业管理
  • sqlserver全文索引
  • Vista下WMC不能播放RMVB解决办法
  • window8.1蓝屏
  • 苹果系统声音怎么设置方法
  • 阿里云安装
  • mac怎么安装安装包
  • win8引导文件
  • python的文件操作中找不到文件应该如何处理
  • python怎么编程
  • opengl入门教程
  • 支付宝是怎么写
  • jquery中判断某个类是否存在的方法
  • shell脚本编程实例
  • 查看项目层级结构怎么查
  • Python性能优化指南
  • jquery 表格插件
  • javascript有哪些常用的属性和方法
  • 安卓手机管家删除的照片怎么恢复
  • 定额发票属于什么类型
  • 国税系统如何查询发票
  • 苏州封闭式高中
  • 地税跟国税是在一起吗
  • 广州地税局官网办事点
  • 疫情期间增值税税率
  • 认缴制什么时候开始的?
  • 免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

    鄂ICP备2023003026号

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

    友情链接: 武汉网站建设