PHP hex2bin() Function
Example
Convert hexadecimal values to ASCII characters:
The output of the above example is:
Hello World!
Definition and Usage
The hex2bin() function converts a string of hexadecimal values to ASCII characters.
Syntax
hex2bin(
string
)
| Parameters | Description |
|---|---|
| string | Required. The hexadecimal values to convert. |
Technical Details
| Return Value: | Returns the ASCII characters of the converted string, or FALSE on failure. |
|---|---|
| PHP Version: | 5.4.0+ |
| Changelog: | Since PHP 5.4.1, a warning is thrown if the string length is odd. In PHP 5.4.0, an odd-length string was silently accepted, but the last byte was removed. |
自 PHP 5.5.1 起,如果字符串是无效的十六进制字符串,则抛出一个警告。 |
PHP String Reference Manual