I use PHP to access a database to get a string like this
‘Chloe’ Fashion Show & Dinner
and then I do a printf() to output the string as html, but my webpage shows this:
�Chloe� Fashion Show & Dinner
All contents are English-based, do I miss something in PHP?
Where should I be checking?
You need to add charset meta tag in 'head' section of html. Note that the meta tag must appear within the first 1024 bytes of rendered page.
<meta charset="utf-8">
in your HTML markup in the<head>
tagIf your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use
utf8_encode($databaseValue)
to ensure the encoding of your value is UTF-8.Make sure that you use:
in the head of your page.