-
- /*
- * Common encoding issues
- *
- * 1. Garbled code problem on the page:
- * The main reason for the garbled code problem on the page is that the encoding of the display font is inconsistent with the encoding displayed in the browser. , the
- * encoding output by the browser is controlled by
- * in the page file, and if you If the characters output in the program are garbled, then the font output by the program is not the same encoding as the one set above, then garbled characters will appear
- * 2. Garbled characters in the database
- * There is a default character encoding in the database. If you If the submitted character encoding is different from the encoding in the data, then the
- * displayed in the database will also be garbled characters
- * (Script Academy bbs.it-home.org)
- * Summary: The reason for the garbled characters is that there are two types of characters caused by different encodings, then we must find a way to make them the same
- *
- * Main points:
- * 1. header settings
- * 2. Database default encoding settings
- * 3. Editor encoding settings (sometimes this is very important,)
- * (The best way is to set these three encodings to be the same)
- *
- * Sometimes if garbled characters appear again, you can also use some encoding conversion functions to convert, as long as the conversion Just change it to the same encoding set in ,
- * Main encoding conversion function
- * mb_convert_encoding(str,to,from)
- * mb_convert_encoding("Hello everyone","gbk","utf-8") (The first encoding is the destination encoding to be converted, and the second is the encoding for the code editor you write)
- *
- * iconv(in,out,str)
- * */
- echo mb_convert_encoding("Hello everyone", "gbk","utf-8");//There will be garbled characters in utf-8, because what you output is the encoding converted to gbk
- echo iconv("utf-8","gbk","Everyone OK");
- ?>
Copy code
|