没有声明HTML文档的字符编码 [英] The character encoding of the HTML document was not declared

查看:92
本文介绍了没有声明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-typecontent =text / html; charset = utf-8/>
< title>插入页面< / title>< / head>
< body>
< h1>插入页面< / h1>
< form action =insert.phpmethod =postenctype =application / x-www-form-urlencoded>
< p>标题:< input type =textname =titlesize =40/>< / p>
< p>价格:< input type =textname =pricesize =40/>< / p>
< p>< input type =submitvalue =Insert/>
< input type =resetvalue =Reset/>< / p>
< / form>
< / body>
< / html>

insert.php:

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

echo $ title;
?>

我不知道我的代码中的问题在哪里。请帮助我。

解决方案

将$ b $添加为HTML模板HEAD部分的第一行b

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


When I click on my form's submit button the following error message appears:

"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 to be declared in the document or in the transfer protocol."

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;
 ?>

I dont know where is the problem in my code. Please help me.

解决方案

Add this as a first line in the HEAD section of your HTML template

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

这篇关于没有声明HTML文档的字符编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆