The word emoticons is a composite of emotion and icon. Emoji, originating from Japan, is another, larger, widely used set of icons. These icons are the little smiley faces, tiny ninjas, and rolling-on-the-floor-laughing icons that are so popular on any website that has a social networking aspect. Prior to PHP 7, however, producing these little beasties was an exercise in frustration.
U+1F648, U+1F649, and U+1F64A

meta tag. You should set the character set to UTF-8. Here is an example:<head> <title>PHP 7 Cookbook</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> </head>
<table>
<tr>
<td>🙈</td>
<td>🙉</td>
<td>🙊</td>
</tr>
</table>"\u{xxx}". Here is an example with the same three icons as in the preceding bullet:<table>
<tr>
<td><?php echo "\u{1F648}"; ?></td>
<td><?php echo "\u{1F649}"; ?></td>
<td><?php echo "\u{1F64A}"; ?></td>
</tr>
</table>In PHP 7, a new syntax was introduced that lets you render any Unicode character. Unlike other languages, the new PHP syntax allows for a variable number of hex digits. The basic format is this:
\u{xxxx}The entire construct must be double quoted (or use heredoc). xxxx could be any combination of hex digits, 2, 4, 6, and above.
Create a file called chap_08_emoji_using_html.php. Be sure to include the meta tag that signals the browser that UTF-8 character encoding is being used:
<!DOCTYPE html>
<html>
<head>
<title>PHP 7 Cookbook</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
</head>Next, set up a basic HTML table, and display a row of emoticons/emoji:
<body>
<table>
<tr>
<td>🙈</td>
<td>🙉</td>
<td>🙊</td>
</tr>
</table>
</body>
</html>Now add a row using PHP to emit emoticons/emoji:
<tr>
<td><?php echo "\u{1F648}"; ?></td>
<td><?php echo "\u{1F649}"; ?></td>
<td><?php echo "\u{1F64A}"; ?></td>
</tr>Here is the output seen from Firefox:
