Ec (2); the role of this article is to avoid the use of UTF-8 encoding and the problem of garbled, does not contain the specific garbled solution and the content of encoding conversion. For a deep understanding of UTF-8 encoding, see: PHP match UTF-8 Chinese Character Regular Expression 1, Editor: Do not use any Microsoft Editor, what front page, WebDesigner, notepad, wordpad or something, can be lost all open, because these editors will generate the script ec (2) Before your UTF-8 document; script
The function of this paper is to avoid the garbled problem caused by the use of UTF-8 encoding in an all-round way, does not contain the specific garbled solution and the content of encoding conversion. For more information about UTF-8 encoding, see PHP Regular Expressions matching Chinese Characters in UTF-8
1. Editor: Do not use any Microsoft Editor, what front page, Web Designer, notepad, WordPad or something, can be lost all open, because these editors will generate BOM in front of your UTF-8 document, BOM specific instructions, can be found here, when I directly take notepad to cover the original file, resulting in a large number of code damage, the memory is still new.
2. MySQL database: when creating databases, creating tables, and creating fields (note that there are three fields), You must select utf8_general_ci sorting format (Collation) and use mysql_connect () in PHP () after the function connects data, you need to add the following sentence:
Mysql_query (''set names "utf8 "'');
3. PHP:
Use the mbstring library instead of the iconv library.
Use preg instead of ereg to process characters.
When using the htmlentities () function, the html_entity_decode () function must contain the third parameter:
CODE:
<? Php
$ Str = "Chinese ";
Echo htmlentities ($ str, ENT_COMPAT, "UTF-8"); // display (inside the source code) Juan?