Home > Backend Development > PHP Tutorial > How to convert string to hexadecimal in php_PHP tutorial

How to convert string to hexadecimal in php_PHP tutorial

WBOY
Release: 2016-07-13 10:02:53
Original
2173 people have browsed it

How to convert a string into hexadecimal in php

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

?

1

2

3

4

5

$string = "Hellotworld!n";

print($string."n");

print(bin2hex($string)."n");

?>

1 2

3

4

5

1

2

3

Hello world!

 

48656c6c6f09776f726c64210a

$string = "Hellotworld!n";

print($string."n");

print(bin2hex($string)."n");

?>

The output results are as follows: ?
1 2 3
Hello world! 48656c6c6f09776f726c64210a
I hope this article will be helpful to everyone’s PHP programming design. http://www.bkjia.com/PHPjc/969348.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/969348.htmlTechArticleHow to convert a string into hexadecimal in php. This article mainly introduces how to convert a string into hexadecimal in php. The hexadecimal method involves the usage skills of the bin2hex function in PHP. It is of great practical value and requires...
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