PHP garbled text-php Tutorial

Source: Internet
Author: User
Easyeclipseforphp is used for programming PHP garbled code. the default encoding is gbk, which can display Chinese characters. There are a lot of written classes on the Internet, take it directly, found that are UTF-8 encoding, the entire program encoding method into the UTF-8, the class of the man part in eclipse can be shown, but garbled characters are displayed in the browser. how can this encoding problem be solved? is there any good solution or suggestion. When the database is added, PHP garbled code may occur.
Program with easyeclipse for php. the default encoding is gbk, which can display Chinese characters.
There are a lot of written classes on the Internet, directly take it to use, found that are UTF-8 encoding, the entire program encoding method changed to UTF-8, class man part in
It can be displayed in eclipse, but it is still garbled in the browser. how can this encoding problem be solved? is there a good solution or suggestion. With the database, garbled code is more likely.

------ Solution --------------------
Change the browser encoding to UTF-8. To save the trouble of modifying the browser encoding every time. Add header ("Content-Type: text/html; charset = utf-8") at the beginning of the row ");

If data is involved. The database encoding is also utf8.
------ Solution --------------------
We recommend that you use UTF-8 for future development. in the future, if you have the opportunity to go to linux or put files on a linux host, it will be much less troublesome.
Especially when it comes to data transmission such as json ajax.
I have suffered from this pain point and began to use gbk. later, I found that many places should consider encoding.

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.