[PHP] solves the problem of html webpage garbled characters. phphtml webpage garbled _ PHP Tutorial

Source: Internet
Author: User
[PHP] solves the problem of html webpage garbled characters, and phphtml webpage garbled characters. [PHP] solves the problem of html webpage garbled characters. phphtml webpage garbled characters often encounter webpage garbled characters when you create a webpage by yourself. In fact, there are several main reasons for webpage garbled text. the [PHP] solution solves the problem of html webpage garbled text, and phphtml webpage garbled text

When you create a webpage by yourself, you may encounter webpage garbled characters.

In fact, there are several main reasons for webpage garbled text. The following provides a solution. 1. encoding of HTML charactersThis problem is common and the most obvious and easy to solve. On the webpageAdd: You can. 2. PHP character encoding problemsThis is similar to the above. Add header ("Content-type: text/html; charset = utf8"); above the file. 3. file encodingNot only are our content encoded, but also the file itself. Use Notepad ++ to open a file and you can see the content displayed in the lower right corner. It is the encoding of the file. You can use the "format" on the Notepad ++ toolbar to convert and encode our files. 4. database coding problemsMySQL data is latin1 encoded by default, so the webpage may be garbled without notice. Use root to enter the database. enter show variables like 'character % 'to view character_set_client character_set_connection.
Character_set_database
Character_set_filesystem
Character_set_results
Character_set_servercharacter_set_system. The set names ut8 command can set character_set_client character_set_connectioncharacter_set_results to utf8. Therefore, when creating a database in MySQL, note that Character setAnd Sorting rulesSet to utf8 ,. Then, in the file connecting to the database, perform mysql_query ("set names UTF8") on the database "). This ensures that the webpage will not be garbled.

When creating a webpage by yourself, the hacker often encounters webpage garbled characters. In fact, there are several main reasons for webpage garbled characters...

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.