Home>Article>Backend Development> How to convert letters to hexadecimal in php
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)" .
The operating environment of this tutorial: windows7 system, PHP7.1 version, DELL G3 computer
php converts letters to hexadecimal System
"; $e = bin2hex("e"); echo($e)."
"; $l = bin2hex("l"); echo($l)."
"; $o = bin2hex("o"); echo($o)."
"; $W = bin2hex("W"); echo($W)."
"; $str = bin2hex("Hello world!"); echo($str); ?>
Output result:
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!