本人刚学习php,属于菜鸟,希望能够得到帮助。我想把我网页头部head和foot,都做成单独的页面,然后在index.php页面中包含就head和foot。使用include ("head.html");语句可以吗?如果不行,有什么好的建议吗?

解决方案 »

  1.   

    不可以,只能include php文件,但是你可以将head.html头部添加<?php ?>空语句,然后将文件保存为php文件。
      

  2.   

    何不试试?呢这是可以的如果.html里,有php代码,请在apache的配置文件里
    AddType application/x-httpd-php  后面加上 .html意思就是.html后缀的,作为php文件来解析。
      

  3.   

    你这样,不会影响html正常的解析?
      

  4.   

    他说的是把html当作php解析  和lz的问题没有关系 不解析也是可以include的
      

  5.   


    貌似不影响解析的AddType application/x-httpd-php 后面加上 .html这样做的目的是,,,如果有人访问file.html,不至于把代码泄露
      

  6.   

    我加上这就话了,AddType application/x-httpd-php 后面加上 .html
    可是还是在php页面不能显示html中的内容啊。
      

  7.   

    麻烦,代码格式,,贴出html文件内容看看
      

  8.   

    在PHP里可以indclude('head.html');
    但不能从html里include('head.php');
      

  9.   

    head.html代码<?php
    <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title> <link rel="stylesheet" type="text/css" href="/computer/css/index.css" /> <script type="text/javascript" src="/computer/lib/jquery.js"></script>
    <script language="javascript" src="/computer/lib/trimpath.js"></script>
    </head>    <body>
            <div class="index_container"> <div class="index_head_container"> <div class="index_head_image_container">
      <a href="/computer/index.html"><img src="/computer/images/logo.gif"></img></a>
    </div> <div class="index_head_content_container">   <ul>
      <li id="index_content_showtime"></li>
    <li>推荐分辨率1024 × 768</li>
      </ul> </div>          </div> <!--隐藏的top信息数据模板层-->
    <div id="index_template_info_top_container" style="display:none">              <embed class="index_head_flash"  pluginspage="http://www.macromedia.com/go/getflashplayer" src="/computer/flash/${info.top_flash}" type="application/x-shockwave-flash"  wmode="transparent" quality="high"></embed>             </div> <!--top信息目标输出层-->
                <div id="index_top_flash_container"></div>

    </div>       </body></html>
    ?>
    <script src="/computer/javascript/head.js"></script>index.php代码<?php
      include("head.php");
    ?>但是head.html中内容不能显示出来啊?
      

  10.   

    如果include "*.*",是把*.*里的数据插入到当前程序。
    如果*.*是PHP脚本,会被解析,如果不是,则原文显示。
      

  11.   

    不管是什么后缀名的文件,php都可以include进来,其中的<?php ?>部分会被解析。其他的部分保持原来的样子输出。。
      

  12.   

    服了既然文件名是.html<?php
      include("head.php");//文件名总要一致吧?????
    ?>如果是纯粹的html文件,,在这个html文件里,就没必要<?php  ?>等格式如果是需要解析的php文件,最好保存为.php吧