PHP HtmlEntities for UTF-8 Characters

If you just use simple PHP htmlentities function with one argument, you will notice that when you pass string that contains UTF-8 characters, the result is incorrect leaving you with some incorrect characters on the result.

To use it correctly, use this code 🙂

htmlentities($your_string, ENT_COMPAT, 'UTF-8');


  1. Hi Xrvel

    im looking for a programmer to write a word press plug-in for me . please email if you are available.. best wishes Jason

Leave a comment

Your email address will not be published.