Lamp server, HTML set meta charset=gb2312, browser request or Utf-8, what's the reason

Source: Internet
Author: User
PHP Default code commented out, Apache's default code also changed, but the Web site is open or garbled? What's the reason?
If you add a PHP header to the interface, the browser will be able to access the normal, but the program is previously written by the old program, not even the unified portal, each file to change the unrealistic
Environment is php5.6,centos6.5
The program on another server is not a problem, Windows native environment is no problem

Reply content:

PHP Default code commented out, Apache's default code also changed, but the Web site is open or garbled? What's the reason?
If you add a PHP header to the interface, the browser will be able to access the normal, but the program is previously written by the old program, not even the unified portal, each file to change the unrealistic
Environment is php5.6,centos6.5
The program on another server is not a problem, Windows native environment is no problem

After meta setting charset, you also need to change the encoding of the file to ANSI. There are many tools to change the encoding of files, and the general editor supports them. I am using EditPlus, there is a "file code" under the Menu "document", can be modified. If Charset=utf-8, then the code of the file is also utf-8. The browser defaults to the encoding of the read file, and meta settings are generally not a priority.

Shouldn't HTML be set to Utf-8??

Not meta BAA ⊙▽⊙

What is the browser encoding? Now the browser's default estimate is Utf-8.
For example, I write a new page encoded as GBK, open with a browser is garbled, Chrome and Firefox are garbled.

Chrome or FF in F12 see if the Content-type in the response header contains the character set you want, check if the Apache settings are appropriate

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.