2013-03-17 68 views
0

我想驗證網站http://www.athometechsolutions.net/index.php,我遇到了麻煩。PHP網站代碼驗證,並不同時驗證

當我鍵入URL到W3驗證服務,我得到以下錯誤:

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有關,因爲當我將塊從include移入常規頭時,錯誤消息位置會發生變化。但是,在我看來,它應該加載得很好(從PHP - Is it dumb to load <head></head> data as an include和其他文件)。

所以,我問,我怎麼能通過URL驗證它?

謝謝!

回答

1

在Notepad ++的HEX編輯器視圖中查看頁面的源代碼顯示,在驗證程序提到的元素元素之前,您有一個字節順序標記。

由於大多數編輯不顯示字節順序標記,所以很難發現。

And, what makes it even more puzzling, is that when I copy and paste the "view-source" code into the W3 validation service, it PASSES.

因爲一個字節順序標記只在文檔的開頭是有道理的,最有可能你的編輯器(或鏈中的另一個組件)安靜的刪除它,當你複製&其粘貼到驗證。