Home  >  Article  >  Backend Development  >  Ten ways to solve UTF-8 encoding in PHP

Ten ways to solve UTF-8 encoding in PHP

WBOY
WBOYOriginal
2016-07-25 08:53:431178browse
  1. [mysql]
  2. default-character-set=utf8
  3. [mysqld]
  4. default-character-set=utf8
  5. default-storage-engine=myisam
  6. Add under [mysqld]:
  7. default-collation=utf8_bin
  8. init_connect='set names utf8'
Copy the code

7. Add in front of the PHP program that needs to do database operations

  1. mb_internal_encoding('utf-8');
Copy the code

8. Add at the end of create table:

  1. engine=myisam default charset=utf8 collate=utf8_bin
Copy code

9.phpmyadmin/config.inc.php

  1. $cfg['defaultcharset'] = 'utf-8';
  2. $cfg['recodingengine'] = 'iconv';
Copy code

10. When phpadmin exports data Uncheck "Use hexadecimal display for binary areas"

Note that file system functions do not support utf-8! It is said that php6 has built-in unicode support, so you can test it if you have the chance.



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