为什么W3C Validator不在HTML5中使用<?php include()标签? [英] Why does the W3C Validator not take <?php include() tags in HTML5?

查看:104
本文介绍了为什么W3C Validator不在HTML5中使用<?php include()标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图验证一个简单的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中使用&lt;?php include()标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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