html php 元字符集 UTF-8 不起作用?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12276817/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
html php meta charset UTF-8 not working?
提问by Boudewijn Smit
Possible Duplicate:
Browser displays ? instead of ´
可能重复:
浏览器显示 ? 代替
i'm kind of stuck on a php file with almost only html in it. I use PHP only to send information from a contact form to my mail adres.
我有点卡在一个几乎只有 html 的 php 文件上。我只使用 PHP 将信息从联系表单发送到我的邮件地址。
When developing the website on localhost everything was all fine. After uploading to my server it messes up the special characters.
在本地主机上开发网站时,一切都很好。上传到我的服务器后,它会弄乱特殊字符。
My meta tag looks like this:
我的元标记如下所示:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
If someone could please help me it would be highly appreciated.
如果有人可以帮助我,将不胜感激。
回答by swapnesh
Add this to the header in your php file and let me know if it solves or not -
将此添加到您的 php 文件的标题中,并让我知道它是否解决了 -
header('Content-Type: text/html; charset=UTF-8');
回答by Boudewijn Smit
If your browser is specifically styled to have the character set as ISO-8859-1or another charset, it will still display in that charset. I think that's the only problem I can detect.
如果您的浏览器被特别设置为将字符集设置为ISO-8859-1其他字符集,它仍将显示在该字符集中。我认为这是我能发现的唯一问题。

