2 回答
It does not work because you got this broken during data fetch and you are setting display encoding - it's already too late. Simply ensure correct encoding during connection by using either using proper method like mysqli_set_charset()
or do query SET NAMES UTF8
just after your connect to DB
Depending on the method you are using to connect to the DB, you should be specifying the charset.
With PDO, you can specify the charset in PDO::__construct()
, such as: charset=UTF-8
Otherwise you have mysqli::set_charset()
for MySQLi, or god forbid you're still using mysql_*
functions there's mysql_set_charset()