PHP bin2hex () function
Examples
The "! Hello World" to hexadecimal values:
<?php
$str = bin2hex("Hello World!");
echo($str);
?>
$str = bin2hex("Hello World!");
echo($str);
?>
Running instance »
Definition and Usage
bin2hex () function to convert a string of ASCII characters to hexadecimal values. String can function by using pack () reconversion back.
grammar
bin2hex( string )
参数 | 描述 |
---|---|
string | 必需。规定要转换的字符串。 |
technical details
return value: | Back to convert a string of hexadecimal values. |
---|---|
PHP version: | 4+ |
More examples
Example 1
A string value from binary to hex and then converted back to:
<?php
$str = "Hello world!";
echo bin2hex($str) . "<br>";
echo pack("H*",bin2hex($str)) . "<br>";
?>
$str = "Hello world!";
echo bin2hex($str) . "<br>";
echo pack("H*",bin2hex($str)) . "<br>";
?>
Running instance »
PHP String Reference