使用php-emoji类让网页显示emoji表情

需要的材料:
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文件
使用php-emoji类让网页显示emoji表情的更多相关文章
- [修正] Firemonkey Android 显示 Emoji (颜文字)
问题:在 Android 平台下,显示 Emoji 文字,无法显示彩色(皆为黑色),例如 Edit 控件,即使将 Edit.ControlType = Platform 设为平台原生控件,还是没用(真 ...
- 修复Arch Linux和Manjaro Linux无法显示emoji的问题
安装好Arch Linux或Manjaro Linux系统后默认没办法正常显示emoji,通常会变成方框或者带有unicode码的方块: 这是因为缺失字体以及相关的字体配置导致的. 当然也有一小部分应 ...
- php 缓存工具类 实现网页缓存
php 缓存工具类 实现网页缓存 php程序在抵抗大流量访问的时候动态网站往往都是难以招架,所以要引入缓存机制,一般情况下有两种类型缓存 一.文件缓存 二.数据查询结果缓存,使用内存来实现高速缓存 本 ...
- IOS 公共类-MyMBProgressUtil Progress显示
IOS 公共类-MyMBProgressUtil Progress显示 此公共类用于显示提示框,对MBProgress的进一步封装.可以看下面的代码 接口: @interface MyMBProgre ...
- asp.net 读取一个文本文件,并输出到网页显示 通过 一般处理程序实现
asp.net 读取一个文本文件,并输出到网页显示 通过 一般处理程序实现 用这个可以做模板首页进行输出,也可以自已自定义进行扩展 //得到读取到的文本到string中 string resultTe ...
- Metro中控件WebView访问外部的网页显示一片空白
Metro中控件WebView访问外部的网页显示一片空白 解决方案: 下载安装了Initex.Software.Proxifier.v3.21.Standard.Edition.Incl.Keyma ...
- python学习笔记--Django入门一 网页显示时间
我的笔记是学习http://djangobook.py3k.cn/ 课程时做的,这个上边的文章讲的确实是非常的详细,非常感谢你们提供的知识. 上一篇随笔中已经配置好了Django环境,现在继续跟随ht ...
- Inno Setup 网页显示插件 webctrl (V2.1 版本)
原文 http://restools.hanzify.org/article.asp?id=90 Inno Setup网页显示插件 webctrl能够显示所有 IE 中能够显示的东西. 引用内容 ; ...
- wamp安装后打开默认网页显示dir,图标红点
首先网页显示dir,是因为服务这些没启动,跟图标红点是一个原因,解决了图标红点,就能解决只显示dir的问题. 先测试是不是端口占用问题,如图: 如果是,那就继续往下走. 单击图标左键(记住是左键),然 ...
随机推荐
- Java client 访问 memcached
在测试项目中引入了memcached作为缓存层,以下是memcached的缓存配置和调用过程. linux下memcached安装过程 直接参考以前的博文linux下安装memcached过程 不再 ...
- nofollow标签如何使用
“nofollow”的意思是不传递权重,向网站站长提供了一种方式,即告诉搜索引擎“不要追踪此网页上的链接”或“不要追踪此特定链接”. nofllow的形式 1.<meta name=" ...
- C# ado.net 使用 row_number over() 简单的分页示例
/// <summary> /// 获取Paging列表 /// </summary> public List<HousesAgentEntity> GetPage ...
- Web前端开发如何利用css样式来控制Html中的h1/h2/h3标签不换行
H1/H2/H3/H4标题标签常常使用在一个网页中唯一标题.重要栏目.重要标题等情形下. H1在一个网页中最好只使用一次,如对一个网页唯一标题使用.H2.H3.H4标签则可以在一个网页中多次出现, ...
- V$SESSION_LONGOPS
对大部分DBA来说,V$SESSION_LONGOPS视图都不会陌生,以前在面试的时候,也有一些企业会问到如何查询数据库中运行时间比较长的SQL,就可以通过这个视图来查看.V$SESSION_LONG ...
- swift-03-数据类型转换
// main.swift // 05-数据类型的转换 // // Created by wanghy on 15/8/9. // Copyright (c) 2015年 wanghy. Al ...
- 根据id设置、获取元素的文本和value
/** * 根据id获取元素文本 * @param {String} id|元素id * return {Integer || String} text */function getText(id){ ...
- MongoDB源码分析——mongod程序源码入口分析
Edit 说明:第一次写笔记,之前都是看别人写的,觉得很简单,开始写了之后才发现真的很难,不知道该怎么分析,这篇文章也参考了很多前辈对MongoDB源码的分析,也有一些自己的理解,后续将会继续分析其他 ...
- 【转】Vim命令合集以及乱码问题解决
乱码问题 """""""""""""""" ...
- 《sort帮你排序》-linux命令五分钟系列之二十六
本原创文章属于<Linux大棚>博客,博客地址为http://roclinux.cn.文章作者为rocrocket. 为了防止某些网站的恶性转载,特在每篇文章前加入此信息,还望读者体谅. ...