Вопрос

I created a simple web site with php pages. I had all pages in the same directory: /var/www/ ; the index.php page is similar to this:

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

When all these php files are in the same directory , the web site works good. If I insert, for example, the page Menu.php in the directory /var/www/NewFolder , the web site doesn't work. I changed the index.php file:

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

Did I make a mistake to write the directory ?

Это было полезно?

Решение

Try this:

include (dirname(__FILE__) . "/NewFolder/Menu.php");
Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top