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

How to convert hexadecimal value to string in php

青灯夜游
Release: 2023-03-14 09:12:02
Original
3908 people have browsed it

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;
?>
Copy after login

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)
Copy after login
  • $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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template