为什么W3C Validator不在HTML5中使用<?php include()标签? [英] Why does the W3C Validator not take <?php include() tags in HTML5?
问题描述
我试图验证一个简单的HTML5页面,它成功验证除了<* c $ c><?php include 三个实例之外的所有内容,这些实例都被标记为错误。我无法弄清楚是什么让它不带PHP标签。为什么会这样?以下是它输出的三个错误:
I was trying to validate a simple HTML5 page, and it successfully validates everything except three instances of <?php include
statements which are marked as errors. I can't figure out what makes it not take the PHP tags. Why would this be? Below are the three errors it outputs:
Validation Output: 3 Errors
Line 29, Column 5: Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)
<?php include("inc/main-menu.php"); ?>
Line 87, Column 9: Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)
2007-<?php echo date("Y"); ?>
Line 94, Column 3: Saw <?. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)
<?php include_once("inc/analytics.php"); ?>
推荐答案
这些PHP标签不应出现在您的标记中。它们将写在您的代码中,但只有您的Web服务器应该看到 - 服务器生成的页面不会显示这些标记。
Those PHP tags should not show up in your markup. They'll be written in your code, but only your web server should see those -the page generated by your server will not have those tags visible.
我猜您是在复制源并粘贴到验证器中?尝试在浏览器中查看页面(假设您正在运行本地Web服务器,如Wamp或Xampp),查看源代码,然后复制并粘贴该代码,而不是直接从编辑器中进行。
I'm guessing you are copying your source and pasting into the validator? Try viewing the page in your browser instead (assuming you are running a local web server, like Wamp or Xampp), view source, and then copy and paste that code, instead of directly from your editor.
这篇关于为什么W3C Validator不在HTML5中使用<?php include()标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!