I've seen this asked several times, but not with a good resolution. I have the following string:
$string = "<p>Résumé</p>";
I want to print or echo the string, but the output will return <p>R�sum�</p>
. So I try htmlspecialchars()
or htmlentities()
which outputs <p>Résumé<p>
and the browser renders <p>Résumé<p>
. I want it, obviously, to render this:
Résumé
And I'm using UTF-8:
header("Content-type: text/html; charset=UTF-8");
What am I missing here? Why do echo
and print
output a �
for any special character? To clarify, the string is actually an entire HTML file stored in a database. The real-world application is not just that one small line.