Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution of Chinese garbled code in php printout

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail the solution to Chinese garbled code in php printout. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

Php printout Chinese garbled solutions: 1, open the php.ini file; 2, find "; default.charset=" UTF-8 ""; 3, remove the previous semicolon; 4, restart the apache service, refresh the page.

This article operating environment: windows7 system, PHP7.1 version, DELL G3 computer

Php printout Chinese garbled how to do?

The solution of Chinese garbled Code output by PHP

Recently, it has been found that there are garbled codes in the Chinese output from the PHP program on windows.

After reading a lot of posts, it is said that you can add it to the page:

The Chinese output in echo is displayed as garbled. In fact, all kinds of server scripts will encounter this problem. It is still a coding problem at all. Generally speaking, for coding compatibility, most pages define the page character set as utf-8. In order to display Chinese normally, you need to change the coding method, such as echo iconv ("GB2312", "UTF-8", "Chinese"). There are other ways to avoid garbled codes, such as adding header ("Content-Type:text/html;charset=gb2312") before the echo of php. Of course, simplified Chinese pages can also simply change the UTF-8 into a strange phenomenon encountered in gb2312. The pages normally displayed on the local server will echo garbled when uploaded to the server. I have not carefully considered this reason, because it is normal to change the location and re-code through the iconv function GB2312 and UTF-8, but it is estimated that it must be APACHE, or rather, it is caused by different settings of the PHP server. Look at PHP.INI and you should be able to solve it.

Add echo iconv ("GB2312", "UTF-8", "Chinese") to each page; or it will be painful.

Finally, when you see that it may be a php.ini file configuration problem, open the php.ini file and find it; default.charset= "UTF-8"-- > default.charset= "UTF-8" remove the previous semicolon (remove comments), restart the apache service, refresh the page, and the Chinese display is normal.

This is the end of this article on "the solution to Chinese garbled code in php printout". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report