📜  PHP | bin2hex()函数

📅  最后修改于: 2022-05-13 01:56:42.743000             🧑  作者: Mango

PHP | bin2hex()函数


PHP中的bin2hex()函数将字符串转换为十六进制值。转换是按字节完成的,首先是高半字节。

注意:它不适用于将表示二进制数字的字符串转换为十六进制。

句法:

bin2hex($string)

参数:此函数接受单个参数$ 字符串 。这是将转换为十六进制值的字符串。

返回值:函数返回参数中传入的字符串的十六进制值。

例子:

Input : string = "geeks"
Output : 6765656b73

Input : string = "1111"
Output : 31313131 
Explanation: "1111" is converted to its hexadecimal 
values, it is not treated as a binary string, else the 
answer would have been F which is not in this case.

下面的程序说明了PHP中的 bin2hex()函数:

方案一:


输出:

6765656b73

方案二:


输出:

31313131 

参考
http:// PHP.net/manual/en/函数.bin2hex。 PHP