]."/> ].">

Home  >  Article  >  Backend Development  >  What should I do if the Chinese characters output by echo in PHP are garbled?

What should I do if the Chinese characters output by echo in PHP are garbled?

王林
王林Original
2020-04-25 13:12:235331browse

What should I do if the Chinese characters output by echo in PHP are garbled?

The Chinese output by echo shows garbled characters, which is basically an encoding problem.

Generally speaking, for the sake of encoding compatibility, most pages define the page character set as utf-8

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

At this time, to display Chinese normally, you need to convert the encoding method, such as

echo iconv("GB2312","UTF-8",&#39;中文&#39;);

This way there will be no garbled characters.

There are other methods, such as adding

header("Content-Type:text/html;charset=gb2312");

in front of php’s echo. For more related tutorials, please pay attention to php中文网.

The above is the detailed content of What should I do if the Chinese characters output by echo in PHP are garbled?. 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
Previous article:What does = mean in phpNext article:What does = mean in php