PHP站点代码验证并且不会同时验证

时间:2013-03-17 01:45:07

标签: validation head php-include

我正在尝试验证网站http://www.athometechsolutions.net/index.php,但我遇到了麻烦。

当我在W3验证服务中键入URL时,出现以下错误:

Error Line 12, Column 1: character data is not allowed here

<meta http-equiv="content-type" content="text/html; charset=UTF-8" />


You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
    putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
    forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
    using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.

但是,我看不出代码有什么问题。更令人费解的是,当我将“view-source”代码复制并粘贴到W3验证服务中时,就会失败。

我真的很喜欢它自己传递它,我无法弄清楚为什么它不会。

在我看来它与文档头部的第一个php包含有关,因为当我将包从include中移出并进入常规头时,错误消息位置会发生变化。但是,在我看来它应该加载得很好(来自PHP - Is it dumb to load <head></head> data as an include和其他文档)。

所以,我问,如何通过URL验证它?

谢谢!

1 个答案:

答案 0 :(得分:1)

在Notepad ++的HEX编辑器视图中查看页面的源代码,可以看出在验证器提到的元元素之前有一个字节顺序标记。

由于大多数编辑都没有显示字节顺序标记,因此很难发现。

  

更令人费解的是,当我将“view-source”代码复制并粘贴到W3验证服务中时,它就会失败。

由于字节顺序标记仅在文档的开头有意义,因此当您将其复制并粘贴到验证器时,编辑器(或链中的其他组件)很可能会将其静默删除。