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

How to convert letters to hexadecimal in php

青灯夜游
Release: 2023-03-13 06:16:02
Original
2268 people have browsed it

In PHP, you can use the bin2hex() function to convert letters into hexadecimal values. This function can convert a string of ASCII characters into hexadecimal values. The syntax is "bin2hex(string)" .

How to convert letters to hexadecimal in php

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

php converts letters to hexadecimal System

<?php
$H = bin2hex("H");
echo($H)."<br>";

$e = bin2hex("e");
echo($e)."<br>";

$l = bin2hex("l");
echo($l)."<br>";

$o = bin2hex("o");
echo($o)."<br>";

$W = bin2hex("W");
echo($W)."<br>";

$str = bin2hex("Hello world!");
echo($str);
?>
Copy after login

Output result:

How to convert letters to hexadecimal in php

Explanation:

bin2hex() function converts a string of ASCII characters into ten Hexadecimal value. Strings can be converted back using the pack() function.

Syntax: bin2hex(string)

Return value: Returns the hexadecimal value of the string to be converted.

Recommended learning: "PHP Video Tutorial"

The above is the detailed content of How to convert letters to hexadecimal 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