PHP page encoding Common settings detailed

Source: Internet
Author: User
Tags php database

php header () function is used to define the encoding of a PHP page (note: There can be no output before, otherwise error)

copy code

3, PHP or HTML file itself encoding: with EditPlus open PHP file or HTML file, save, select the encoding, if the database and page encoding is GBK, then the code here choose ANSI; If the database and page encoding is Utf-8, then Utf-8 is also selected here. The data passed in

4, JavaScript, or Flash is utf-8 encoded, and if the database and page encoding is GBK, transcoding is done and then written to the database.

  1. iconv (' utf-8 ', ' GBK ', $content);
copy code

5, in a PHP program, you can add a line to specify the code of the PHP source program: Header (' Content-type: text/html; CHARSET=GBK ');

Four, coded character case difference (only in MySQL, other places are recommended uppercase UTF-8, GBK, GB2312) only in MySQL can use "utf-8" Alias "UTF8", but in other places use uppercase "UTF-8". Specifically, the command "mysql_query (set names UTF8)" is capitalized "UTF-8".

The above describes the PHP set page encoding methods, as well as PHP database encoding, page encoding, encoding character case of the problem, I hope to be helpful.

  • 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.