PHP handles app emoji emoticons and iOS emoticons and MySQL save instance of phone emoticons

Source: Internet
Author: User
Usage Scenario: PHP as the server-side receive app interface data, due to MySQL format problem caused by no way to directly save emoticons package

The solution is to convert the expression to Base64 can be seen in the format, due to the length of the conversion is too large, replace it with the corresponding characters saved into the database


<?php class emoji{/** * Turns the expression to the corresponding representative string * @param string $content */        public static function Emojiencode ($content = ") {if (! $content) {return $content;        } $content = Json_encode ($content);        $emoji = requrie_once (' emoji.php ');        $content = Str_replace (Array_keys ($emoji [' Regenencode ']), $emoji [' Regenencode '], $content);        $content = Json_decode ($content, true);    return $content;        /** * Convert the corresponding string into an expression * @param string $content */public static function Emojidecode ($content = ") {        if (! $content) {return $content;        } $content = Json_encode ($content);        $emoji = requrie_once (' emoji.php ');        $content = Str_replace (Array_keys ($emoji [' Regendecode ']), $emoji [' Regendecode '], $content);        $content = Json_decode ($content, true);    return $content; }}

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.