I have checked around here and the Internet but I could not solve my issue:
First off, I am using the PHP include command to include files from other folders into my various files (I hope that I make sense here).
Now to the issue at hand:
In terms of appearance everything works fine EXCEPT although the text loads OK, the pictures/icons do not load appropriately (see picture below):
As you can see the icon appears broken
When I click on the href of the included files I get this, as if the link does not exist:
Finally, when I move my files to the root directory everything works perfectly!
But when I move my files (the ones that will later on include the rest) to their respective folders I am confronted with the above issues.
And here are two examples of what I do:
Case 1: when all files are located in the root_folder
<?php include('../../include_files/footer.php'); ?>
the include_files is the folder in which all files to be included are located
(In this case I have: RootMenu -> include_files -> footer.php <---which is the file to be included)
Case 2: When I move my files to their folders I use:
<?php include('../../include_files/footer.php'); ?>
(In this case I have: RootMenu -> files -> TestsRun -> testfile.php <---which is the file that uses the included)
It loads the file to be included but bringing with it the above mentioned problems (I use Apache - XAMPP).
When you include files in PHP, the paths to the images and other "includes" begin with whatever the current working directory is. Here's what I'd do to track down your problem. At the start of the script, add these lines:
echo getcwd();
This will show you the directory from which all of your image paths should begin. When using includes, the included file becomes essentially part of the main (or calling) script so you should use the path of your main or calling script was your base path.
For example:
If my script "main.php" is in /scripts/stuff. If in main.php I have an include such as "include ../../morestuff.php". The current working directory is still /scripts/stuff so any paths to images and other files within morestuff.php will start with /scripts/stuff. I explained that poorly, I know.