Home >Backend Development >PHP Tutorial >The difference between php page encoding and mysql database encoding

The difference between php page encoding and mysql database encoding

WBOY
WBOYOriginal
2016-07-25 08:53:55844browse
Copy the code

3. The encoding of the 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 utf-8 encoded: Note that the data passed in JavaScript or Flash is UTF-8 encoded. If the database and page encoding is GBK, it needs to 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:

  1. header('content-type: text/html; charset=gbk');
Copy code

php page encoding 1. Set the encoding in the file header

  1. @header('content-type: text/html;charset=utf-8');
  2. ?>
Copy code

2. The difference between header and meta The difference between using @header('content-type: text/html; charset=gbk'); and Both tell the browser what encoding to use to display the web page. If there is any difference, header sends the original http header and leaves nothing in the web page, while meta is written in the web page. For one, if there is no meta in the web page, then sending the http header will work. Second, use the header() function to send the original http header, which can contain more content, and setting the encoding is only one of them. Third, sometimes it is not necessary to display any content on the web page, but it is necessary to inform the browser what encoding to use for subsequent actions.



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