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
<?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); ?>
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!