php - 如何修复 HTML 文档的字符编码未声明

标签 php html mysql

我的网站在 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/

相关文章:

php - 我如何编写一个查询来获取 mysql 中的计数

php - 获取开始日期到结束日期之间的日期,以 php 月份明智计数

java - 使用Java格式将rtf转换为html

从数据库中获取数据的表中包含复选框的 PHP 文件?

php mysql 这里有什么问题

javascript - 在每个 span 元素上画圆圈

javascript - html或javascript,如何找出程序文件文件夹在哪里?

php - 这个 INNER JOIN SQL 查询有什么问题?

php - MYSQL 中的 IP 地址被截断

php - Mysql数据转PHP数组,然后显示?