In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "what is the root of the page garbled problem". The content in the article is simple and clear, and it is easy to learn and understand. let's go deep into the editor's train of thought. Let's study and learn "what is the root of the page garbled problem"!
First, close default_charset in the PHP configuration file php.ini:
1. Page does not specify charset, Apache configuration defaultcharst gbk, page file encoding is utf-8
Result: garbled code. Use wireshark to grab the packet and find that the header returned by the server indicates:
The copy code is as follows:
Content-Type:text/html;charset=GB
Conclusion: when the page does not specify charset, the defaultcharset of Apache works
two。 The page specifies charset as utf-8, and Apache configures defaultcharset gbk. The page file is utf-8
The copy code is as follows:
Test Apache DefaultCharset
As a result, there is still garbled code.
Conclusion: when Apache is configured with DefaultCharset, the charset declaration of the page will be ignored.
3. PHP header declares that charset is utf8, Apache configures defaultcharst gbk, and the page file encoding is utf8
The copy code is as follows:
Header ("Content-Type:text/html; charset=utf-8")
Result: the page appears normal.
4 Apache set DefaultCharset off
As a result, the page appears normal.
Flipped through Apache2's manual:
AddDefaultCharset instruction
Indicates the default character set added to the HTTP reply header when the reply content is text/plain or text/html
Syntax AddDefaultCharsetOn | Off | charset
Default value AddDefaultCharsetOff
Scope serverconfig,virtualhost,directory,.htaccess
Override item FileInfo
State Core (C)
Module core
This instruction will be added to the HTTP reply header when and only if the reply content is text/plain or text/html
The default character set. In theory, this will overwrite the character set specified by tagging in the document body, but in practice
Usually depends on the settings of the user's browser. AddDefaultCharsetOff will disable this feature.
AddDefaultCharsetOn enables the default character set iso-8859-1 within Apache. You
You can also specify another charset in the name of the character set registered with IANA.
For example:
AddDefaultCharsetutf-8
That is, when Apache does not specify defaultcharset, the page encoding is specified by the page's own meta tag.
When Apache is specified, the encoding specified by the meta tag in the page is ignored. But allow the script to be directly header encoded to the client.
Thank you for your reading, the above is the content of "what is the root of the page garbled problem". After the study of this article, I believe you have a deeper understanding of what is the root cause of the page garbled problem. the specific use of the situation also needs to be verified by practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.