I’m having a problem with htmlentities()
$txt = "árbol";
echo $txt; // outputs: árbol
echo htmlentities($txt); // outputs: árbol (árbol)
The second echo should output árbol (á)
I’m using utf-8:
<meta charset="utf-8">
What’s going on? Thank you!
You have to set the third parameter of
htmlentities()which tells the charset to use. Because of you don’t set it, the default is used and the default is ISO-8859-1, not UTF-8.Just to clarify, this is the function signature:
and here you’ll find the official doc: http://php.net/manual/en/function.htmlentities.php