Reputation: 123
I have to following file structure:
ROOT
index.html
INCLUDES
header.html
footer.html
FOLDER1
FOLDER2
FOLDER3
FOLDER4
file.php
When I use
include('includes/header.html');
in my index.html
file, the header is pulled in correctly.
However, I cannot get it to traverse the file structure from file.php
. I have tried the following:
include('../../../../includes/header.html');
Can you spot what I am doing wrong? Is there a way to do it so I can just specify
include('includes/header.html');
regardless of which page I am on?
Upvotes: 0
Views: 362
Reputation: 639
$var=(dirname(dirname(__FILE__)).'/');
require_once($var.'header.html');
echo $var;//you find how many directory back you are
Upvotes: 0
Reputation: 1585
The default method to do this is to adjust the include_path variable from php, so any file can include your library folder, regardless of the filesystem position.
Upvotes: 0