Basic Question Regarding PHP Includes

Posted on 16th Feb 2014 by admin

Hi

Just starting out with PHP.

Working on a site that uses some basic includes, these are working fine for all my files in the root of my site as the links from the header include is just linking straight to pages for example contactUs.php

I am now however having to create some new folders to hold some product ranges, these are two folders down from the root of the site. I can link to the includes fine but the links don't work, to work they would need ../../ etc

Now I could create a new header include file especially for use by the files in the deeper folders or I could make the links absolute but I just wondered if there was another way?

I wondered if you could use PHP to perhaps detect the folder level and then add the necessary path???

I don't know am I way off the mark?

Any help / tips much appreciated.

Other forums