How to display Emoji on my Web Broswer using PHP [duplicate]

有些话、适合烂在心里 提交于 2019-12-30 15:42:36

问题


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.


回答1:


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!



来源:https://stackoverflow.com/questions/46020947/how-to-display-emoji-on-my-web-broswer-using-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!