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

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

WBOY
Release: 2016-06-13 12:20:37
Original
2024 people have browsed it

求助求助!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 />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template