提问者:小点点

未声明HTML文档的字符编码


单击表单的“提交”按钮时,将出现以下错误消息:

“未声明HTML文档得字符编码.如果文档包含来自US-ASCII范围之外得字符,则在某些浏览器配置中,文档将呈现乱码文本.必须在文档或传输协议中声明页面得字符编码.”

insert.html:

<!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 http-equiv="content-type" content="text/html; charset=utf-8" />
<title>insert page</title></head>
<body>
<h1> Insert Page </h1>
    <form   action="insert.php"  method="post"  enctype="application/x-www-form-urlencoded" >
    <p>Title:<input type="text"  name="title" size="40"/></p>
     <p>Price:<input type= "text"  name="price" size="40" /></p>
     <p><input type="submit" value="Insert" />
    <input type="reset"  value="Reset" /></p>
    </form>    
</body>
</html>

insert.php:

<?php
   $title = $_POST["title"];
   $price = $_POST["price"];

  echo $title;
 ?>

我不知道我的代码出了什么问题。请帮帮我.


共2个答案

匿名用户

在HTML模板的HEAD部分中添加这一行作为第一行

<meta content="text/html;charset=utf-8" http-equiv="Content-Type">
<meta content="utf-8" http-equiv="encoding">

匿名用户

我对最基本的情况也有同样的问题,我的问题通过在头部插入这个元来解决:

<meta charset="UTF-8">

html文档的字符编码(实际上是UTF-8)没有声明

相关问题