为什么PHP需要这样一种奇怪的方式来指定UTF-8?

为什么PHP需要这样一种奇怪的方式来指定UTF-8?,php,html,utf-8,Php,Html,Utf 8,重音字符没有在PHP中显示,所以我添加了 标题('Content-Type:text/html;charset=UTF-8') 到页眉。还是没有快乐。但我已经解决了: <!DOCTYPE html> <html> <head> <?php header('Content-Type: text/html; charset=UTF-8"'); ?> <meta http-equiv="Content-type" co

重音字符没有在PHP中显示,所以我添加了 标题('Content-Type:text/html;charset=UTF-8') 到页眉。还是没有快乐。但我已经解决了:

<!DOCTYPE html>
<html>
<head>
<?php
header('Content-Type: text/html; charset=UTF-8"');
?>
<meta http-equiv="Content-type" content="text/html" charset=utf-8" / >
</head>
<body>
  Hélène
</body>
</html>

Notice the difference?  Why should a single double quote before the final single quote make all the difference?
If I drop the php making an html file and insert a double quote before utf-8 in the meta tag the way it should be then it doesn't work!
I'm using Chrome Version 88.0.4324.150 (Official Build) (64-bit) - haven't tested with other browsers.


我不明白你的问题,但在任何情况下,你都可以使用HTML5中的
标记

<meta charset="utf-8">


此代码不起作用。在已经开始输出内容后,无法输出标题。这也不是标题的有效语法。你应该仔细检查一下你的测试,因为它似乎是无效的。“为什么在最后一个单引号之前的一个双引号会产生所有的差异?”-好吧,有时候两个错误会产生正确的结果。然而,仔细考虑哪一个打字错误被恢复是离题的。