【问题标题】:Index file conflict with include files索引文件与包含文件冲突
【发布时间】:2014-05-28 05:32:19
【问题描述】:

我的index.php 和“包含文件”有问题。我的 index.php 文件位于名为 mysite 的主文件夹内,其中的其余部分是 subfolders 以及各自的 .php 文件。除了index.php 之外,子文件夹文件运行良好。每次我在浏览器中预览时,包含文件都会弄乱。

index.php 文件的路径如下:

mysite/index.php

include files 的路径如下:

mysite/pages/include/header.php

这是包含包含文件的 HTML 文件:

<html>
   <head>

   <?php 
   include ("pages/include/headertop.php");
   include ("pages/include/header.php");
   include ("pages/include/nav.php"); 
   ?>

   </head>
</html>

如果我在这里遗漏了什么,请纠正我。

顺便说一句,我正在使用 XAMPP。

谢谢你和更多的力量!

【问题讨论】:

    标签: php html css include


    【解决方案1】:

    编辑你的 index.php:

    include ("../pages/include/headertop.php");
    include ("../pages/include/header.php");
    include ("../pages/include/nav.php");  
    

    然后再试一次“mysite/index.php”

    【讨论】:

      【解决方案2】:

      首先确保您在 .php 文件而不是 .html 文件中调用这些包含命令。 其次,确保您的服务器已启动并运行良好。 在此之后尝试此代码:

      <html>
         <head>
      
         <?php 
         include "pages/include/headertop.php";
         include "pages/include/header.php";
         include "pages/include/nav.php"; 
         ?>
      
         </head>
      </html>
      

      P.S:只需从包含中删除括号。 还请确保文件名正确且大小写正确。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2023-03-06
        • 1970-01-01
        • 2019-12-24
        • 2016-01-12
        • 2017-12-22
        相关资源
        最近更新 更多