PHP garbled problem Summary and solution

Source: Internet
Author: User
PHP garbled problem Summary and solution

Garbled has always been a very big problem for PHP beginners, and now summarizes the reasons for the PHP website garbled and Solutions :

First, HTML page encoding:

Meta Http-equiv=content-type content=text/html; Charset=utf-8 the code here and database encoding, and connection database coding;

Second, the file storage code:

For example, file inde.php, changing its storage encoding to the desired encoding. Simply save the text-editing software file as EditPlus and select the correct encoding in the encoding

(Many people will ignore this);

Third, the database code:

For example, with phpMyAdmin Selecting a database, select the action option. The following is a collation, which should also be set to a unified code;

Four, the table code:

The operation is similar to the 3rd. There is no repetition here;

Five, field code:

In the construction of the table in the field, there is a collation. If the content has Chinese characters, it must be changed to a unified code;

Vi. database operation encoding settings:

When connecting to the database mysql_select_db (), add a sentence mysql_query (set names UTF8);

Seven, the local test after the successful website, to go online, there will be garbled.

It may be that the correct encoding is not selected when the data is exported locally, so there is a garbled problem after importing to the Web.

In fact, as long as careful, you can completely solve the PHP garbled problem, difficult is not technology, 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.