Home >Backend Development >PHP Tutorial >head above water PHP page encoding declaration method detailed explanation of header or meta

head above water PHP page encoding declaration method detailed explanation of header or meta

WBOY
WBOYOriginal
2016-07-29 08:42:101119browse

php header to define a php page as utf encoding or GBK encoding
php page as utf encoding
header("Content-type: text/html; charset=utf-8");
php page as gbk encoding
header(" Content-type: text/html; charset=gb2312");
The PHP page is encoded in big5
header("Content-type: text/html; charset=big5");
Usually the above code is placed on the homepage of the PHP page
The difference between using header or meta to implement PHP page encoding
1. Page encoding
1. Use
  3. Encoding of PHP or html file itself: open php with editplus When saving a file or HTML file, select the encoding. If the database and page encoding is gbk, then the encoding here is ANSI; if the database and page encoding is UTF-8, then UTF-8 is also selected here.
 4. Another thing to note is that the data passed in Javascript or Flash is encoded in utf-8. If the database and page encoding is gbk, it must be transcoded and then written to the database.
iconv('utf-8', 'gbk', $content);
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');

The above introduces the head above water PHP page encoding declaration method and explains the header or meta in detail, including the content of head above water. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn