Home >Backend Development >PHP Tutorial >How to convert string to hexadecimal in php_PHP tutorial
This article mainly introduces the method of converting a string into hexadecimal in php, involving the bin2hex function in php The usage tips are of great practical value. Friends in need can refer to them
The example in this article describes how PHP converts strings into hexadecimal. Share it with everyone for your reference. The specific analysis is as follows:
In php, you can use the bin2hex function to convert the string into hexadecimal form and output it. The bin2hex() function returns the result as ascii code
?
3 4
5
|
print($string."n"); print(bin2hex($string)."n"); ?>
|
1
2
3 |
Hello world! 48656c6c6f09776f726c64210a |