Home  >  Article  >  php教程  >  让ThinkPHP支持Emoji , 并能存入Mysql

让ThinkPHP支持Emoji , 并能存入Mysql

WBOY
WBOYOriginal
2016-06-07 11:39:301093browse

Thinkphp默认的utf8不支持Emoji,因为Emoji是unicode编码,每个Emoji占4个字节,只要把数据表和列的编码都改为utf8mb4即可
网上找了一堆文章都没写清楚。

Thinkphp默认的utf8不支持Emoji,因为Emoji是unicode编码,每个Emoji占4个字节,按照如下方法做肯定可以用。

1、确保mysql版本大于5.3.3(支持utf8mb4)
2、把表字符集改为utf8mb4, 排列顺序为utf8mb4_general_ci
3、把字段字符集改为utf8mb4, 排列顺序为utf8mb4_general_ci

utf8mb4是utf8的延伸并向下兼容,大可放心用,不过记得备份

有部分emoji还是显示为问号,如有更好的方法请指教。

AD:真正免费,域名+虚机+企业邮箱=0元

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