Differences between php page encoding and mysql database encoding

Source: Internet
Author: User
Differences between php page encoding and mysql database encoding

3. php or html file encoding: use editplus to open the php file or html file. if the database and page encoding are gbk, the encoding here is ansi. if the database and page encoding are UTF-8, then UTF-8 is also used.

4. the data transmitted in javascript or flash is UTF-8 encoded. Note that the data transmitted in javascript or flash is UTF-8 encoded. if the database and page encoding are gbk, transcoding is required, then write the data to the database. Iconv ('utf-8', 'gbk', $ content); 5. You can add a line in the php program to specify the encoding of the php source program:

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

Php page encoding 1. set encoding in the file header

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

2. for the difference between header and meta, use @ header ('content-type: text/html; charset = gbk '); The difference between the two is to tell the browser what encoding is used to display the web page, what is the difference, the header is to send the original http header, not left in the web page, and meta is written in the web page. First, if the webpage does not contain meta, sending the http header will take effect. Second, use the header () function to send the original http header, which can contain more content. encoding is only one of them. Third, in some cases, do not display any content on the webpage, but notify the browser of the encoding used for subsequent actions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.