And just to further clarify, here's a current working problem.
First, here's a couple of directories/files for this example:
ROOT/index.php
ROOT/includes/ <-- location of all included files
ROOT/images/ <-- location of all images
ROOT/main/
ROOT/main/sitemap/sitemap.php
ROOT/products/products.php
And here's how I include the specified file on the various pages:
<?php include($_SERVER['DOCUMENT_ROOT'] . "/includes/header.php"); ?>
When i include the header.php file from the index.php, which is in the root, it works fine. Further, when I include the header.php file, into the products.php page, which is located in the products directory (one directory deeper than root), it still works fine.
But here's something just plain weird. When I include the header.php file, into the sitemap.php file, located in the sitemap folder, which in turn is located in the main folder, which in turn is located in the root, it does not work properly.
And what i mean is the following. sitemap.php DOES include the header.php file. That is not the problem. I can see the html showing up. However, the images, which are part of the included file, are not showing up. Instead, you get the typical red box with an X, implying that the image is not there. And when I click on the properties for this "image", it tells me that it is trying to pull the specified image from:
ROOT/main/images/blahblah
BUT THERE IS NO "images" folder under main. So basically, for some reason, when the included file is included into the sitemap.php file, it is not properly referencing the relative image links to their appropriate directory (here, i'm referring the relative links located within the include file).
An included file is often used throughout all pages of a site, which generlly includes several different levels of navigation. So if one uses relative path links in the included file, these links will be broken and cause problems when the included file is used within different levels of the website...UNLESS, php is supposed to not allow this to happen.
Any reasons for this? Perhaps something I am doing wrong?