Convert "Hello World!" to hexadecimal values:
<?php
$str = bin2hex("Hello World!");
echo($str);
?>
Try it Yourself »
The bin2hex() function converts a string of ASCII characters to hexadecimal values. The string can be converted back using the pack() function.
bin2hex(
string)
Parameter | Description |
---|---|
string | Required. The string to be converted |
Return Value: | Returns the hexadecimal value of the converted string |
---|---|
PHP Version: | 4+ |
Convert a string value from binary to hex and back:
<?php
$str = "Hello world!";
echo bin2hex($str) . "<br>";
echo pack("H*",bin2hex($str)) . "<br>";
?>
Try it Yourself »
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!