Home >php教程 >php手册 >thinkphp supports emoji and can be stored in mysql

thinkphp supports emoji and can be stored in mysql

WBOY
WBOYOriginal
2016-09-02 08:42:171149browse

In the Thinkphp environment, Mysql stores Emoji
The default utf8 of Thinkphp does not support Emoji, because Emoji is unicode encoding, and each Emoji occupies 4 bytes. Just change the encoding of the data table and columns to utf8mb4.

Thinkphp's default utf8 does not support Emoji, because Emoji is unicode encoding, and each Emoji occupies 4 bytes, as follows:
1. Make sure the mysql version is greater than 5.3.3 (supports utf8mb4)
2. Change the table character set to utf8mb4, and the sort order is utf8mb4_general_ci
3. Change the field character set to utf8mb4, and the sort order is utf8mb4_general_ci

utf8mb4 is an extension of utf8 and is backward compatible. Remember to back up.

Some emoji are still displayed as question marks, please refer to the following:
Modify the data connection configuration 'database encoding' to: 'DB_CHARSET'=> 'utf8mb4',
The field character set also needs to be modified to uf8mb4
Only then can it be stored normally! ! ! !

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