Home >Backend Development >PHP Tutorial >!01字符长串转换成16进制字符串的函数

!01字符长串转换成16进制字符串的函数

WBOY
WBOYOriginal
2016-06-13 12:20:372032browse

求助求助!01字符长串转换成16进制字符串的函数
如题,php里面有没有这个函数.....


------解决思路----------------------
01字符长串 就是二进制字符串了, 用 bindec 可转换成十进制数
10 进制数可用 dechex 转换成 16 进制字符串

echo dechex(bindec('011101')); //1d

不过要注意有效数位的长度
------解决思路----------------------
二进制转16进制,
可先转为10进制,然后在转为16进制。

<br />$s = '01';<br />echo dechex(bindec($s)); // 1<br />

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