Home  >  Article  >  Backend Development  >  How to convert characters in php ascii

How to convert characters in php ascii

藏色散人
藏色散人Original
2020-07-27 10:16:575204browse

php ASCII conversion method: first use the header method to set the encoding format of the page to utf8; then save the ASCII value to be converted in the $order variable; then use the chr function to convert the ASCII value into characters ; Finally, use echo to output the result.

How to convert characters in php ascii

Recommended: "PHP Tutorial"

Convert ASCII values ​​to characters in php

Create a new php file named test.php to explain how to convert ASCII values ​​into characters in php.

How to convert characters in php ascii

In the test.php file, use the header() method to set the encoding format of the page to utf-8 to avoid outputting Chinese garbled characters.

How to convert characters in php ascii

In the test.php file, save the ASCII value to be converted in the $order variable, for example, the ASCII value here is a hexadecimal value 0x61.

How to convert characters in php ascii

In the test.php file, use the chr() function to convert the ASCII value from the previous step into characters and save it in the $res variable.

How to convert characters in php ascii

In the test.php file, use echo to output the results on the page.

How to convert characters in php ascii

Open the test.php file in the browser to view the results.

How to convert characters in php ascii

The above is the detailed content of How to convert characters in php ascii. For more information, please follow other related articles on the PHP Chinese website!

Statement:
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