一些字符变成“ ”在我的渗透 [英] Some characters become "�" in my wepage

查看:118
本文介绍了一些字符变成“ ”在我的渗透的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP访问数据库以获取这样的字符串


'Chloe'Fashion Show&晚餐


然后我做一个printf()输出字符串作为HTML,但我的网页显示:


Chloe Fashion Show&晚餐


所有内容都是基于英文的,我想在PHP中错过什么?



请放一些灯,所以我知道我应该在哪里检查。谢谢。

解决方案


  1. 检查.php文件是否编码为没有BOM的UTF-8

  2. 检查您的连接是否为UTF-8

  3. 检查您是否发送 < head> 标签中的HTML标记中的元charset =utf-8>

如果你与数据库的连接不是UTF-8,你不想改变它(但我推荐它 - >所有UTF-8都是最安全的解决方案反对字符垃圾)使用 utf8_encode($ databaseValue) ,以确保您的值的编码为UTF-8。


I use PHP to access a database to get a string like this

‘Chloe’ Fashion Show & Dinner

and then I do a printf() to output the string as html, but my webpage shows this:

�Chloe� Fashion Show & Dinner

All contents are English-based, do I miss something in PHP?

Please shed some lights so I know where I should be checking. Thanks.

解决方案

  1. Check if your .php file is encoded as UTF-8 without BOM
  2. Check that your connection to the database is UTF-8
  3. Check that you send <meta charset="utf-8"> in your HTML markup in the <head> tag

If your connection to the database is not UTF-8 and you don't want to change it (but I recommend it -> everything UTF-8 is the most secure solution against character rubbish) use utf8_encode($databaseValue) to ensure the encoding of your value is UTF-8.

这篇关于一些字符变成“ ”在我的渗透的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆