我的网站在 localhost
中运行,没有任何错误;但是当我将我的网站添加到 CPpanel 并运行 members.php
时,页面消失了(它显示白色背景)。
检查控制台显示中的页面此错误消息:
The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
检查元素仅显示这些行:
<div style="clear:both;"></div>
</div>
</div>
</body>
</html>
最佳答案
根据您收到的错误,请将其添加到您的 <head> ... </head>
中:
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-5">
如果上面的字符集不起作用,请尝试以下操作:
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
我希望您将页面的前 BODY 部分定义为:
<!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<HEAD>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">
<title> Your Title</title>
</HEAD>
<BODY>
....
编辑2:
在将其他任何其他 PHP 文件包含在 members.php
中之前,首先输入这一行:
header('Content-type: text/html; charset=utf-8');
关于php - 如何修复 HTML 文档的字符编码未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26481021/