If you add htmlspecialchars()
function after replacing the smileys with HTML Tags. It will not work correctly.
Output will be as
<strong>Name :</strong> I am Happy <img src="happy.png">
There are two solution to make it work.
Soln 1 :
Don't convert the text into emoticons before storing it in database. While showing it to the user.
First use htmlspecialchars()
, then use strireplace()
.
Soln 2:
First convert the whole message using htmlspecialchars()
, then convert the emoticons using strireplace()
. After that, Store the result in the database.