简体   繁体   English

HTML正确的UTF8和PHP HTML输出混乱

[英]Utf8 in html correct and php html output messed up

This issue is mind-boggling to me. 这个问题令我难以置信。 I am facing the following situation. 我正面临以下情况。 I wrote a website in html using the utf8 charset. 我使用utf8字符集以html编写了一个网站。 Special characters are displayed as expected. 特殊字符将按预期显示。 Now I want to give out some php mysql results, so the easiest way is to create a php file, include the html code and then give out the results. 现在,我想给出一些php mysql结果,因此最简单的方法是创建一个php文件,包括html代码,然后给出结果。 However the html given out via the php file does not display the special characters correctly... it's not utf8 但是,通过php文件给出的html不能正确显示特殊字符...不是utf8

here is the html version: HTML 这是html版本: HTML

and here the exact copy in a php file: HTML VIA PHP 此处是php文件中的确切副本: HTML VIA PHP

To close this question myself (because I feel rather stupid right now), the one who actually solved this is Marc B as his comments made me understand the process of text encoding. 为了自己解决这个问题(因为我现在觉得自己很愚蠢),实际上解决了这个问题的是Marc B,他的评论使我理解了文本编码的过程。

After setting the header (Content Type and charset) as well as setting the meta tag in HTML I discovered, just like Marc suspected that my IDE had encoded the php file in another encoding than UTF8. 在设置了标题(内容类型和字符集)并在HTML中设置了meta标签后,我发现了,就像Marc怀疑我的IDE用除UTF8之外的另一种编码方式编码了php文件。 Saving the file as UTF8 and replacing the messed up specialchars fixed my issue. 将文件另存为UTF8并替换混乱的Specialchars解决了我的问题。

Please excuse this, I wasn't fully aware of what I was doing. 请原谅,我不知道自己在做什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM