Reputation: 11
I have PHP pages in diffrent directorys in my root eg.
http://mydomain.com/forum/?action=thread&threadid=9284
http://mydomain.com/library/?s=achievements
I need to include a file on every php document which is in root dir.
include('header.php');
does not work
On for example /root/forum/index.php
i want to include header.php that is in /root/header.php
which is in /root/
My english is not best but I hope you understand. Thank you.
Upvotes: 1
Views: 115
Reputation: 2066
There are a couple ways to do this:
You can add your header into php default include path:
set_include_path("/path/to/includes");
You can make this change permanent by changing your php.ini file.
You can create a variable/define which is the common default root folder:
$path=dirname(__FILE__
);
include($path."header.php");
Upvotes: 5