I am using ent package for Encode and decode HTML entities in one of my nodejs project. An example conversion is given below
var ent = require('ent');
let encodeString = ent.encode( 'Lorem Ipsum Dolor 542 O’ipsum for ❤️ dummy' ) ;
encodeString give result as Lorem Ipsum 🚲 Dolor 542 O’ipsum for ❤️ dummy
But I cannot reproduce the same result when I tried in php, Code is give below
$string = addslashes(trim(htmlentities('Lorem Ipsum Dolor 542 O’ipsum for ❤️ dummy', ENT_COMPAT, "UTF-8")))
Result: Lorem Ipsum Dolor 542 O’ipsum for ❤️ dummy
Expected: Lorem Ipsum 🚲 Dolor 542 O’ipsum for ❤️ dummy
Someone please help me to achive the same result in php same as the one obtained from nodejs ent.encode
Note: DB collation as utf8mb4_unicode_ci and saving without encode doesn't work for some emoji's. I found that If I could save date in php as Lorem Ipsum 🚲 Dolor 542 O’ipsum for ❤️ dummy
It will work correctly.