The purpose of this paper is to avoid the garbled problem caused by the use of UTF-8 encoding, which does not contain the specific garbled solution and the content of the code conversion. For an in-depth understanding of UTF-8 coding, refer to: "Regular expressions for text characters in PHP matching UTF-8"
1, Editor: Do not use any Microsoft editor, what Frontpage,web Designer, Notepad, WordPad and so on, can throw away all, because these editors will be in front of your UTF-8 document generated BOM, the specific description of the BOM, can be found here, That year I directly to the Notepad to UTF-8 overwrite the original file, causing a lot of code damage, still fresh memory.
2, MySQL database: Pay attention to build a library, build a table, build a field (note there are three places), should choose Utf8_general_ci Format (Collation), in PHP using the mysql_connect () function to connect the data, you need to add a sentence:
mysql_query (' Set names ' utf8 "');
3. PHP:
Use the MB library and do not use the Iconv library.
Use Preg instead of using Ereg to handle characters.
With the Htmlentities () function, the Html_entity_decode () function takes a third argument:
$str = "Chinese";
Echo htmlentities ($str, Ent_compat, "UTF-8"); Display (inside the source code) <a href= ' Test ' > Juan?
http://www.bkjia.com/PHPjc/632493.html www.bkjia.com true http://www.bkjia.com/PHPjc/632493.html techarticle The purpose of this paper is to avoid the garbled problem caused by the use of UTF-8 encoding, which does not contain the specific garbled solution and the content of the code conversion. In-depth knowledge of UTF-8 coding ...