I'm trying tp display Emojis from my database to Web Browser. I tried to input emoji from my phone to my app and it is saved to database as 'ðŸ˜'. How can I display it to PHP as emoji like this . Thank you in Advance.
Asked
Active
Viewed 1,090 times
-1
-
There is a php lib on github https://github.com/iamcal/php-emoji which may help here. – Alexander Sep 03 '17 at 06:46
-
You may need to make sure you database collation is set to utf8mb4. This might help https://stackoverflow.com/questions/7814293/how-to-insert-utf-8-mb4-characteremoji-in-ios5-in-mysql – OrderAndChaos Sep 03 '17 at 06:48
1 Answers
2
You need to configure your database connection like the following:
$db = new mysqli('localhost', 'username', 'password', 'db_name');
if ($db->connect_error) {
die("Connection failed: " . $db->connect_error);
}
$db->query("SET character_set_client='utf8mb4'");
$db->query("SET character_set_results='utf8mb4'");
$db->query("set collation_connection='utf8mb4_bin'");
And ensure your HTML file is UTF-8, have the following in between the head tags:
<meta charset="utf-8">
Hope it helps. Cheers!

Shatadip Majumder
- 114
- 5