bin2hex

(PHP 4, PHP 5, PHP 7, PHP 8)

bin2hex将二进制数据转换为十六进制表示

说明

bin2hex(string $string): string

返回 ASCII 字符串,包含 string 的十六进制表示。转换是高位优先,按字节完成的。

参数

string

字符串。

返回值

返回指定字符串的十六进制表示。

范例

示例 #1 bin2hex() 示例

<?php

$hex
= bin2hex('Hello world!');

var_dump($hex);
var_dump(hex2bin($hex));
?>

以上例程会输出:

string(24) "48656c6c6f20776f726c6421"
string(12) "Hello world!"

参见

  • hex2bin() - 转换十六进制字符串为二进制字符串
  • pack() - 将数据打包成二进制字符串

add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top