包含功能的问题

时间:2014-05-03 16:10:15

标签: php include

我用php页面创建了一个简单的网站。我把所有页面放在同一目录中:/ var / www /; index.php页面与此类似:

    <?php 
     include ("Header.php");
     include ("Menu.php");
     include ("Content.php");
     include ("Footer.php");
    ?> 

当所有这些php文件都在同一目录中时,网站运行良好。例如,如果我在目录/ var / www / NewFolder中插入了Menu.php页面,那么该网站就不起作用了。我更改了index.php文件:

   <?php
    include ("Header.php");
    **include ("NewFolder/Menu.php")**;
    include ("Content.php");
    include ("Footer.php");
   ?>

我写错了目录吗?

1 个答案:

答案 0 :(得分:0)

试试这个:

include (dirname(__FILE__) . "/NewFolder/Menu.php");