dongyuan7981 2014-11-24 18:33
浏览 35
已采纳

在php mysql中不显示变音符号和特殊字符

I have written a small social network on my pc in my localhost xampp. Here everything works fine.

Text in my mySQL Database looks like this: "was für pizza?" instead of "was für Pizza?". This is fine, it is displayed like "was für Pizza?" in my localhost on my PC.

But now I uploaded it to my Webspace and there I got this "was für pizza?" displayed.

Can anyone help me?

  • 写回答

3条回答 默认 最新

  • duangua5742 2014-11-24 19:23
    关注

    Some steps:

    • Make sure your table/columns are set to a unicode collation. An older, but still good one is utf8_unicode_ci. It works for most cases, but if you're going to have emoji (which you might with a social network) you'll want to use utf8mb4_unicode_ci.
    • Make sure that PHP's connection with the database is UTF8. This is generally accomplished by running the query SET names 'utf8'
    • Make sure your website is telling the browser that it's UTF8. This is generally accomplished by sending the Content-Type: text/html;charset=utf-8 header, by including a meta tag that says the same thing, <meta http-equiv="Content-Type" content="text/html;charset=utf-8" /> or by including a meta-charset tag (newer) <meta charset="utf-8" />
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 表达式必须是可修改的左值
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写
  • ¥20 Qcustomplot缩小曲线形状问题