Ten steps to solve the problem of using UTF-8 encoding in PHP

Source: Internet
Author: User
& Nbsp; previously said that if the JS file is not UTF8 will have bugs in IE, so JS code should also use UTF-8. There are also databases to use UTF-8. Php (as the mainstream development language) with UTF-8 Summary: php (as the mainstream development language) file itself must be UTF-8 encoding. Unlike Java, clas is generated

Previously said that if the JS file is not UTF8 will have bugs in IE, so JS code also use UTF-8. There are also databases to use UTF-8.
Php (as the mainstream development language) with UTF-8 summary:

  1. Php (as the mainstream development language) files must be UTF-8 encoding. Unlike Java, class files are generated to avoid this problem.
  2. Php (as the current mainstream development language) to the output header: header ("Content-Type: text/html; charset = UTF-8 ″)
  3. Meta tags do not matter. all browsers with headers will parse them by header.
  4. UTF8 is required for all peripherals, including databases, *. js, and *. css (CSS has little impact)
  5. Php (as the mainstream development language) is not Unicode, and all functions such as substr must be changed to mb_substr (mbstring extension is required ); or use iconv transcoding (basically linux is installed. if it is not installed, download, tar, make, and make install are very simple)
  6. My. ini:
    [MySQL (best combination with PHP)]
    Default-character-set = utf8
    [MySQL (the best combination with PHP) d]
    Default-character-set = utf8
    Default-storage-engine = MyISAM
    Add the following to [MySQL (the best combination with PHP) d:
    Default-collation = utf8_bin
    Init_connect = set names utf8
  7. Add
    Mb_internal_encoding (UTF-8 );
  8. Add ENGINE = MyISAM default charset = utf8 COLLATE = utf8_bin to the last side of create table.
  9. Php (as the mainstream development language) MyAdmin/config. inc. php (as the mainstream development language)
    $ Cfg [DefaultCharset] = UTF-8;
    $ Cfg [RecodingEngine] = iconv;
  10. When exporting data in php (as the mainstream development language) Admin
    Remove the "Display in hexadecimal format in binary ".

Particularly depressing: file system functions do not support UTF-8!

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.