[英]Why does the W3C Validator not take <?php include() tags in HTML5?
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. 我试图验证一个简单的HTML5页面,它成功验证除了三个
<?php include
语句实例之外的所有内容, <?php include
语句被标记为错误。 I can't figure out what makes it not take the PHP tags. 我无法弄清楚是什么让它不带PHP标签。 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"); ?>
Those PHP tags should not show up in your markup. 这些PHP标记不应出现在您的标记中。 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服务器应该看到这些 - 您的服务器生成的页面不会显示这些标记。
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.
尝试在浏览器中查看页面(假设您正在运行本地Web服务器,如Wamp或Xampp),查看源代码,然后复制并粘贴该代码,而不是直接从编辑器中查看。
<?php
is not valid HTML in any dialect. <?php
在任何方言中都不是有效的HTML。 An HTML parser should never see <?php
tags, since they're evaluated on the server. HTML解析器永远不应该看到
<?php
标签,因为它们是在服务器上进行评估的。 As such, it's correct that the validator complains. 因此,验证者抱怨是正确的。
<\\?php include() ?>
is PHP tag which needs to be rendered by PHP processor. <\\?php include() ?>
是需要由PHP处理器呈现的PHP标记。 It's not a valid HTML tag 它不是有效的HTML标记
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.