PHP MySQL support emoji expression scheme

Source: Internet
Author: User
Tags php mysql

Convert emoji to UTF8 and store to database, but inefficient

1  Public functionRrr$text) {2         $text= ' A?? Ss?? Ss?? ss;3         //emoji symbols for handling names4         $tmpStr= Json_encode ($text);//exposing the Unicode5 6         $TMPSTR 1=Preg_replace_callback("# (\\\ue[0-9a-f]{3}) #i",function($a) {7             //var_dump ($a);8             return addslashes($a[1]);9             //return $a;Ten},$tmpStr); One         $text= Json_decode ($TMPSTR 1);  A         return $TMPSTR 1; -}

Direct MySQL support: Requires more than 5.5 of the version

default character Set:utf8mb4. default collection:utf8mb4_general_ci; corresponding table: Commentdefault character Set:utf8mb4. default collection:utf8mb4_general_ci; corresponding field: Content: Character Set:utf8mb4.    Collection:utf8mb4_general_ci;

PHP-side database encoding to be changed to UTF8MB4

It's relatively perfect.

PHP MySQL support emoji expression scheme

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.