Hi,
I've create an application which uses PHP includes which works great if you don't mind having the PHP include files in the same place as the other files. But I would like to split my code up as neatly as possible. Please see the below file structure:
As you can, I would like all ?.php files to be in the document root and for all php-related include files (eg. database connection details) to be in the 'inc' folder.
For the html and corresponding css, images etc, I created a 'templates' folder to hold all the details with a sub-folder called 'includes' which will hold the html includes such as header, footer etc.
Unfortunately, even though my images and css are in the same place as my html templates, the css and images don't seem to show when viewing the site (although the text part of the header/footer do).
Ive been trying to do some research and understand that using something like
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/common/header.php";
include_once($path);
might be a way forward, but i am new to PHP and wasn't sure where to put it, or which route to specify. I also understand that this method can vary depending on whether it is on an apache, linux or windows server. ideally i want the method to work on all servers. I am currently developing on a local apache server on a mac.
Thanks very much for your help Theresa