I have a mysql database that's set to utf-8.
I have set my php header to: header("Content-Type: text/html; charset=utf-8");
and in my html:
When I return anything that has round quotes or apostrophes, they show up as unrecognized characters (black diamond with a ? inside).
If I run utf8_encode () on the string I'm echoing out, it looks fine in Chrome, but shows a different weird character in Firefox. Is there something else I can do site-wide to make this work better?
(I've accessed the db with sequel pro and phpmyadmin)
解决方案
full utf-8 settings:
1) .htaccess
AddDefaultCharset utf-8
PHP_VALUE default_charset utf-8
2) after mysqli_connect() in php call this:
mysqli_query($this->link, 'SET character_set_client="utf8",character_set_connection="utf8",character_set_results="utf8"; ');
3) your DB should be created with "collation: utf8" charset; all fields in table also should be "collation: utf8"
4) your PHP files also should be created with utf8 charset