"; in front of the output of the ThinkPHP program."/> "; in front of the output of the ThinkPHP program.">

Home  >  Article  >  PHP Framework  >  What should I do if thinkphp outputs Chinese garbled characters?

What should I do if thinkphp outputs Chinese garbled characters?

爱喝马黛茶的安东尼
爱喝马黛茶的安东尼Original
2019-08-22 15:51:094327browse

What should I do if thinkphp outputs Chinese garbled characters?

thinkphp’s solution to Chinese garbled output:

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

This sentence defines your PHP file output encoding, but does not define the browser encoding of the HTML file, that is, the template.

This situation occurs because your development program does not define HTML encoding, and the default encoding of your browser is not uniform, so garbled characters are output.

Related recommendations: "ThinkPHP Tutorial"

Solution:

1. Modify the browser's default encoding The default encoding for the program.

2. Add an HTML Header output in front of the output of the ThinkPHP program:

echo "<meta http-equiv=&#39;Content-Type&#39;&#39; content=&#39;text/html; charset=utf-8&#39;>";

Then, the Chinese content that comes out when accessing your echo will basically not be garbled.

The above is the detailed content of What should I do if thinkphp outputs Chinese garbled characters?. 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