Home > Backend Development > PHP Tutorial > Solve the garbled problem of PHP beginners_PHP tutorial

Solve the garbled problem of PHP beginners_PHP tutorial

WBOY
Release: 2016-07-21 14:52:52
Original
811 people have browsed it

Garbled characters have always been a very big problem that troubles PHP beginners. Now we will summarize the causes and solutions of garbled characters:
1. HTML page encoding: meta http-equiv=content-type content=text/html ; charset=utf-8 The encoding here must be consistent with the database encoding and the connection database encoding;
2. The storage encoding of the file: For example, the file inde.php, change its storage encoding to the required encoding. Just use text editing software such as EditPlus to save the file as, and select the correct encoding in the encoding (many people will ignore this);
3. Database encoding: For example, if you use phpmyadmin, select the database and select the operation option. There is an arrangement below, which should also be set to a unified encoding;
4. Table encoding: The operation is similar to the third point. I won’t repeat it here;
5. Field encoding: When creating fields in a table, there is an arrangement. If the content contains Chinese characters, it must be changed to a unified encoding;
6. When connecting to the database, add the sentence mysql_query (set names utf8) after mysql_select_db();
7. Local test (just encountered) After the successful website is uploaded to the Internet, there will be garbled characters. It may be that the correct encoding was not selected when exporting data locally, so there will be garbled characters after importing to the web.
In fact, as long as you are careful, you can completely solve the php garbled problem. The difficulty is not technology, but carefulness. (www.bkjia.com)

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/371459.htmlTechArticleGarbled characters have always been a very big problem that troubles PHP beginners. Now we will summarize the causes and solutions of garbled characters. : 1. HTML page encoding: meta http-equiv=content-type content=t...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template