Enable ThinkPHP to support Emoji and store it to Mysql

Source: Internet
Author: User
Provides various official and user-released code examples. For code reference, you are welcome to exchange and learn Thinkphp's default utf8 does not support Emoji, because Emoji is unicode encoded and each Emoji occupies 4 bytes, you only need to change the data table and column encoding to utf8mb4.
I found a bunch of articles on the Internet and did not write them clearly.

The default utf8 of Thinkphp does not support Emoji because Emoji is unicode encoded and each Emoji occupies 4 bytes. You can use the following method.

1. Ensure that mysql version is later than 5.3.3 (utf8mb4 is supported)
2. Change the table character set to utf8mb4 and arrange the order utf8mb4_general_ci.
3. Change the field character set to utf8mb4 and arrange the order utf8mb4_general_ci.

Utf8mb4 is an extension of utf8 and is backward compatible, so you can use it with confidence, but remember to back up

Some emoji are still displayed as question marks. For more information, see.

AD: truly free, domain name + VM + enterprise mailbox = 0 RMB

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.