PHP code example of yangshihe / yii2-emoji

1. Go to this page and download the library: Download yangshihe/yii2-emoji library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yangshihe / yii2-emoji example snippets




后端部分
use yangshihe\emoji\Emoji;

//实现方式: (比如微信公众号的昵称含有表情)则如下:
$emoji = new Emoji();
$nickname = $emoji->emoji_unified_to_html($data['nickname']);
// OR
$nickname = (new Emoji())->emoji_unified_to_html($data['nickname']);

// 然后存入数据库神马的
//........

//前端部分 需要视图的部分//
use yangshihe\emoji\EmojiAsset;

//按需加载
EmojiAsset::register($this->getView());

//OR
//依赖加载
//AppAsset.php

    public $depends = [
        'yii\web\YiiAsset',
        .......code.........
        'yangshihe\emoji\EmojiAsset'
    ];

// 然后你就能看到和微信一模一样的表情了.