Several PHP Chinese garbled characters are worth noting that Chinese garbled characters in PHP are one of the common problems in PHP development. Website construction: Chinese garbled characters in www. ucantech. comPHP sometimes occur on the webpage. Some are generated during MySQL interaction and sometimes related to the operating system. The following is a summary. I. First of all, the best and fastest solution for PHP webpage encoding is that the page declarative encoding is consistent with the internal encoding of the database. if the page numbers requested by the page are several PHP Chinese characters garbled, it is worth noting that
PHP Chinese garbled characters are one of the common problems in PHP development.
Website construction: http://www.ucantech.com/
PHP Chinese garbled characters sometimes occur on the web page, and some occur in the MySQL interaction process, sometimes related to the operating system. The following is a summary.
I. first, PHP webpage code
The best and fastest solution is that the encoding of the page declaration is consistent with the internal encoding of the database. if the requested page number is inconsistent with the internal encoding of the database, set the connection encoding, mysql_query ("set names kkk"); KKK is the connection encoding. it will certainly solve the garbled problem.
1. the PHP file encoding should match the webpage encoding. if you want to use gb2312 encoding, php needs to output the header ("Content-Type: text/html; charset = gb2312") and add it to the static page. The encoding format of all files is ANSI, which can be opened in Notepad. save it as ANSI and overwrite the source file. B. If you want to use UTF-8 encoding, php needs to output headers: header ("Content-Type: text/html; charset = utf-8") and add static pages The encoding format of all files is UTF-8. It may be a little troublesome to save it as UTF-8. generally, BOM is generated at the beginning of the UTF-8 file. If session is used, problems may occur. you can use editplus to save it in editplus, tool-> parameter selection-> File-> UTF-8 signature, select the total is to delete, and then save to remove the BOM information.
2. php itself is not Unicode. all functions such as substr must be changed to mb_substr (mbstring extension is required), or iconv transcoding is used. Fblww-0105)