Php webpage garbled

Source: Internet
Author: User

I haven't written php for a long time. Today, when I was in use, I suddenly encountered a strange garbled error. I was amazed !, Let's take a look at my troubleshooting methods and give a reference to my friends who have encountered the same problem.

There is a long project that needs to be restarted inexplicably today. This project is the xampp environment-do you know xampp? You can Google it. I will not talk about it anymore.

At the beginning, we were familiar with apahce configuration and php configuration ...... There is no problem along the way. When I started to access the page, the problem came up. It was strange to expect that the page could be run, but there was an unexpected garbled problem.

The first thing that comes to mind is that the default Character Set of apache is added to the Language extension configuration file of apache:

Adddefacharcharset UTF-8

My website page is UTF-8. Restarting does not work as expected-that is, it does not work! Multi-party efforts have no effect, so it wasted half an hour on httpd. conf. Getting depressed ......

Half an hour later, I smoked a cigarette and thought that phpinfo may be helpful. So I opened phpinfo and immediately got stunned. In the Content-Type item in the HTTP Response Headers column, the text/html gbk is displayed. I am a God-why is it gbk. So I searched for the settings again. httpd. conf didn't, And all the extensions didn't have the gbk stuff ......

Depressed ......

Php. ini, this is finally found. I don't know which kind of cool person opened the settings of this place, and it's not correct. Where?

Default_charset = "gbk"

This is the place where Lao Tzu is killed! Then modify it:
Default_charset = UTF-8 ″

Restart. Everything is normal! But we can't harm people either. We want to get rid of the code and see if we can. After the removal, everything is still normal-the page shows that the encoding control is re-returned to the page itself.

 

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.