Home > PHP Framework > ThinkPHP > body text

What should I do if thinkphp outputs Chinese garbled characters?

爱喝马黛茶的安东尼
Release: 2019-08-22 15:51:09
Original
4310 people have browsed it

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");
Copy after login

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;>";
Copy after login

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!

Related labels:
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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!