Home >Backend Development >PHP Tutorial >Detailed explanation of common settings for PHP page encoding
php's header() function is used to define the encoding of a php page (note: there cannot be any output in front, otherwise an error will be reported) 3. Encoding of PHP or html file itself: Use editplus to open the php file or html file. When saving, select the encoding. If the database and page encoding is gbk, select ansi as the encoding here; if the database and page encoding is utf-8, select utf-8 here as well. 4. The data passed in Javascript or Flash is encoded in utf-8. If the database and page encoding is gbk, it needs to be transcoded and then written to the database.
5. In the PHP program, you can add a line to specify the encoding of the PHP source program: header('Content-type: text/html; charset=gbk'); 4. The difference between upper and lower case of encoding characters (Only in mysql, other places recommend using uppercase UTF-8, GBK, GB2312) Only in MySQL can the alias "utf8" of "utf-8" be used, but in other places, always use uppercase "UTF-8". Specifically: always use uppercase "UTF-8" outside the command "mysql_query(set names utf8)". The above introduces the various methods of setting page encoding in PHP, as well as the issues of database encoding, page encoding, and encoding character case in PHP. I hope it will be helpful to everyone. |