Home  >  Article  >  Backend Development  >  如何将一个64bit整型编码为网络字节序列?

如何将一个64bit整型编码为网络字节序列?

WBOY
WBOYOriginal
2016-06-06 20:36:591167browse

项目需要:将一个64bit整型编码为网络字节序列,我知道在php5.6.3以上版本可以使用pack('J',$bigint),但这样就得跟新php版本了,运维不同意,现在公司用的是php5.4.9 操作系统为64位linux ,我想问在这种情况下,怎么进行64bit整型编码转换

回复内容:

项目需要:将一个64bit整型编码为网络字节序列,我知道在php5.6.3以上版本可以使用pack('J',$bigint),但这样就得跟新php版本了,运维不同意,现在公司用的是php5.4.9 操作系统为64位linux ,我想问在这种情况下,怎么进行64bit整型编码转换

<code>pack("NN", $big >> 32 , $big)
</code>

没内建支持就自己拆吧。实在不行把它拆成正确顺序的8个8位然后挨个转成字节就是了。

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:视图模型countNext article:activerecord表关联查询