需要的材料:

  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表情的更多相关文章

  1. [修正] Firemonkey Android 显示 Emoji (颜文字)

    问题:在 Android 平台下,显示 Emoji 文字,无法显示彩色(皆为黑色),例如 Edit 控件,即使将 Edit.ControlType = Platform 设为平台原生控件,还是没用(真 ...

  2. 修复Arch Linux和Manjaro Linux无法显示emoji的问题

    安装好Arch Linux或Manjaro Linux系统后默认没办法正常显示emoji,通常会变成方框或者带有unicode码的方块: 这是因为缺失字体以及相关的字体配置导致的. 当然也有一小部分应 ...

  3. php 缓存工具类 实现网页缓存

    php 缓存工具类 实现网页缓存 php程序在抵抗大流量访问的时候动态网站往往都是难以招架,所以要引入缓存机制,一般情况下有两种类型缓存 一.文件缓存 二.数据查询结果缓存,使用内存来实现高速缓存 本 ...

  4. IOS 公共类-MyMBProgressUtil Progress显示

    IOS 公共类-MyMBProgressUtil Progress显示 此公共类用于显示提示框,对MBProgress的进一步封装.可以看下面的代码 接口: @interface MyMBProgre ...

  5. asp.net 读取一个文本文件,并输出到网页显示 通过 一般处理程序实现

    asp.net 读取一个文本文件,并输出到网页显示 通过 一般处理程序实现 用这个可以做模板首页进行输出,也可以自已自定义进行扩展 //得到读取到的文本到string中 string resultTe ...

  6. Metro中控件WebView访问外部的网页显示一片空白

    Metro中控件WebView访问外部的网页显示一片空白 解决方案: ​下载安装了Initex.Software.Proxifier.v3.21.Standard.Edition.Incl.Keyma ...

  7. python学习笔记--Django入门一 网页显示时间

    我的笔记是学习http://djangobook.py3k.cn/ 课程时做的,这个上边的文章讲的确实是非常的详细,非常感谢你们提供的知识. 上一篇随笔中已经配置好了Django环境,现在继续跟随ht ...

  8. Inno Setup 网页显示插件 webctrl (V2.1 版本)

    原文 http://restools.hanzify.org/article.asp?id=90 Inno Setup网页显示插件 webctrl能够显示所有 IE 中能够显示的东西.  引用内容 ; ...

  9. wamp安装后打开默认网页显示dir,图标红点

    首先网页显示dir,是因为服务这些没启动,跟图标红点是一个原因,解决了图标红点,就能解决只显示dir的问题. 先测试是不是端口占用问题,如图: 如果是,那就继续往下走. 单击图标左键(记住是左键),然 ...

随机推荐

  1. 跨时钟域设计【二】——Fast to slow clock domain

    跨时钟域设计中,对快时钟域的Trigger信号同步到慢时钟域,可以采用上面的电路实现,Verilog HDL设计如下:   // Trigger signal sync, Fast clock dom ...

  2. JQuery事件的绑定

    关于jQuery事件绑定html: <a href="#" onclick="addBtn()">addBtn</a> <div ...

  3. Asp.Net 如何获取所有控件&如何获取指定类型的所有控件

    一. Asp.Net Page页面中访问所有控件的属性为: Page.Controls 控件的结构是树结构. 二.获取指定类型所有控件实例: 1.递归方法定义: private void GetCon ...

  4. C语言-求1-20的阶乘的和(函数的递归)

    // //  main.c //  C语言 // //  Created by wanghy on 15/9/5. //  Copyright (c) 2015年 wanghy. All rights ...

  5. 注释玩转webapi

    using System; using System.Collections.Generic; using System.Net.Http.Formatting; using System.Web.H ...

  6. javascript 基础3第13节

    <html> <head> <title>javascript基础</title> </head> <body> 1.流程控制 ...

  7. Javascript中数组方法汇总

    Array.prototype中定义了很多操作数组的方法,下面介绍ECMAScript3中的一些方法: 1.Array.join()方法 该方法将数组中的元素都转化为字符串并按照指定符号连接到一起,返 ...

  8. QT5新手上路(1)安装

    这几天学了一下windows下的QT,也不算什么心得吧,就是谈一下我的做法.希望看到这篇随笔的菜鸟们略有所得,少走弯路. 闲话少说,先说安装.首先是选版本,我用的是qt-opensource-wind ...

  9. 学习笔记---C++伪函数(函数对象)

    C++里面的伪函数(函数对象)其实就是一个类重载了()运算符,这样类的对象在使用()操作符时,看起来就像一个函数调用一样,这就叫做伪函数. class Hello{ public: void oper ...

  10. IOS 学习笔记 2015-03-24 OC-API-不可变字符串

    大部分是模仿// // main.m // OC-API-不可变字符串 // // Created by wangtouwang on 15/3/25. // Copyright (c) 2015年 ...