Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use php hex to ascii

Shulou Source: shulou.com Published: 2022-06-03 16:13:28 10月18日 Update

In this issue, the editor will bring you about how to use php hex to ascii. The article is rich in content and analyzes and narrates it from a professional point of view. I hope you can get something after reading this article.

In php, you can convert a string of hexadecimal values into ASCII characters through the hex2bin () function, whose syntax is "hex2bin (string)", and the parameter string represents the hexadecimal value to be converted.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

How to transfer php hex to Ascii?

The hex2bin () function converts a string of hexadecimal values into ASCII characters.

Grammar

Hex2bin (string)

Parameters.

String is required. The hexadecimal value to convert.

Return value: returns the ASCII character of the converted string, or FALSE if it fails.

PHP version: 5.4.0+

Update log:

As of PHP 5.4.1, a warning is thrown if the string length is odd. In PHP 5.4.0, odd-digit strings are silently accepted, but the last byte is removed.

As of PHP 5.5.1, a warning is thrown if the string is an invalid hexadecimal string.

Example

Convert hexadecimal values to ASCII characters:

The output of the above code:

Hello World! The above is the editor for you to share how to use php hex to ascii, if you happen to have similar doubts, you might as well refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.

Tags: Characters strings hexadecimal content functions parameters odd syntax parsing professional small and medium code rich in content can be passed bytes instances that is articles logs more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi Microsoft Apple OPPO Reno Linux