Easily solve the problem of confusing PHP beginners

Source: Internet
Author: User
Garbled text has always been a big problem for beginners. Now we will summarize the causes and solutions for garbled text. Garbled text has always been a major problem that has plagued PHP beginners. The following describes the causes and solutions for garbled text:

I. HTML page encoding:Meta http-equiv = content-type content = text/html; charset = utf-8 the encoding here must be the same as the database encoding and connection database encoding;

II. file storage encoding:For example, the file inde. php changes its storage encoding to the required encoding. You only need to use EditPlus and other texts to edit software files and save them as files. select the correct encoding in the encoding (this will be ignored by many people );

III. database code:For example, if phpmyadmin is used to select a database, select the Operation option. There is an arrangement below, which should also be set to a unified encoding;

IV. table encoding:The operation is similar to the third point. We will not repeat it here;

V. Field Encoding:When creating fields in a table, sort the fields. If the content contains Chinese characters, it must be changed to a unified encoding;

6. after mysql_select_db () is connected to the database, add mysql_query (set names utf8 );

7. after the local test is successful, the website will be uploaded to the Internet with garbled characters. It may be because the correct encoding is not selected when exporting data locally, so it will cause garbled characters after being imported to the web.

In fact, as long as you are careful, you will be able to completely solve the php garbled problem. The difficulty is not technical, but careful.

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.