需要的材料:
php-emoji类库的下载地址:https://github.com/iamcal/php-emoji
代码示例:(该代码来自官网)
<?php
    include('emoji.php');
    # when you recieve text from a mobile device, convert it
    # to the unified format.
    //当你从移动设备里接收到信息,要将这些信息转为统一格式
    //以下4个函数是从其他设备的格式转为统一格式
    $data = emoji\_docomo\_to\_unified($data);   # DoCoMo devices
    $data = emoji\_kddi\_to\_unified($data);     # KDDI & Au devices
    $data = emoji\_softbank\_to\_unified($data); # Softbank & pre-iOS6 Apple devices
    $data = emoji\_google\_to\_unified($data);   # Google Android devices
    # when sending data back to mobile devices, you can
    # convert back to their native format.
    //以下4个函数是从统一格式转为其他设备能使用的格式
    $data = emoji\_unified\_docomo($data);   # DoCoMo devices
    $data = emoji\_unified\_kddi($data);     # KDDI & Au devices
    $data = emoji\_unified\_softbank($data); # Softbank & pre-iOS6 Apple devices
    $data = emoji\_unified\_google($data);   # Google Android devices
    # when displaying data to anyone else, you can use HTML
    # to format the emoji.
    //从统一格式转为html格式
    $data = emoji\_unified\_to\_html($data);
    # if you want to use an editor(i.e:wysiwyg) to create the content, 
    # you can use html\_to\_unified to store the unified value.
    $data = emoji\_html\_to\_unified(emoji\_unified\_to\_html($data));
**实现网页显示emoji表情的步骤:**
  一、下载php-emoji
  **二**、在html文件里导入emoji.css文件
  三、在脚本里导入emoji.php文件
  完整代码:
<!doctype html>
<html>
    <head>
        <meta http-equiv="content-type" content="text/html;charset=utf-8"/>
        <!-- 导入emoji.css文件,切记一定要导入 -->
        <link rel="stylesheet" type="text/css" href="./php\_emoji/emoji.css">
    </head>
    <body>
        <div id="chatContent">
            <?php
                //导入php\_emoji类
                include('./php\_emoji/emoji.php');
                //$data是emoji表情的数据
                $data = emoji\_unified\_to\_html($data);
                //此时就能echo出emoji表情
                echo $data;
            ?>
        </div>
    </body>
</html>
备注:一定要导入emoji.css文件
本文为wjw原创文章,转载无需和我联系,但请注明来自wjw博客http://wjiawen.cn
 
                
最新评论