setting utf8 with mysql through php

后端 未结 2 900
忘了有多久
忘了有多久 2020-12-21 23:12

I have the following very simple code, which retrieves utf8 formatetd data, such as containing umlauts from a mysql database, which may or may not be set as utf8. If I use e

2条回答
  •  北荒
    北荒 (楼主)
    2020-12-21 23:35

    Perhaps the error lies in the charset you're serving the page with. If you're getting UTF-8 content out of the database and serving it with the default HTML charset of Windows-1252 then it's going to look garbled. Make sure you have the equivalent of this:

    header( 'Content-Type: text/html; charset=utf-8' );
    

    in your PHP code.

提交回复
热议问题