tags:

views:

38

answers:

2

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.

+5  A: 

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");

Rodrigo
+1 for remembering include_path
Mark Baker
A: 

You could use include '../header.php'.

Anders S
This is the simple solution.
kiamlaluno