Home  >  Article  >  Backend Development  >  How to convert hexadecimal value to string in php

How to convert hexadecimal value to string in php

青灯夜游
青灯夜游Original
2021-12-01 18:49:513871browse

In PHP, you can use the hex2bin() function to convert hexadecimal values ​​into strings. The function of this function is to convert hexadecimal values ​​into ASCII encoded character values. The syntax "hex2bin (hex value)".

How to convert hexadecimal value to string in php

The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer

In PHP, you can use hex2bin () function to convert a hexadecimal value to a string.

Example:

<?php
$hexstr="48656c6c6f20576f726c6421";
$str=hex2bin($hexstr);
echo $str;
?>

Output:

How to convert hexadecimal value to string in php

## Description:

hex2bin() function can convert hexadecimal values ​​into ASCII encoded character values.

Syntax:

hex2bin($string)

  • $string: Specifies the hexadecimal value to be converted and cannot be omitted.

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

Recommended learning: "

PHP Video Tutorial"

The above is the detailed content of How to convert hexadecimal value to string in php. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn