UTF-8 problems PHP/MySQL

后端 未结 7 1177
隐瞒了意图╮
隐瞒了意图╮ 2020-12-05 12:08

I\'ve always used ISO-8859-1 encoding, but I\'m now going over to UTF-8.

Unfortunately I can\'t get it to work.

My MySQL DB is UTF-8, my PHP document is enco

7条回答
  •  春和景丽
    2020-12-05 12:31

    Remember to set connection encoding to utf8 as well.

    In ext\mysqli do $mysqli->set_charset("utf8")

    In ext\mysql do mysql_set_charset("utf8")

    With other db extensions you might have to run query like SET NAMES 'utf8'

    Some more details about connection encoding in MySQL

    As others point out, making sure your source code is utf-8 encoded also helps. Pay special attention to not having BOM (Byte Order Mark) - it would be sent to browser before any code is executed, so using headers or sessions would become impossible.

提交回复
热议问题