When you include files in PHP like you are currently doing (providing only the filename, such as header.php
), PHP will look in the same directory as the file currently being executed.
From I understand of your description (I struggled to understand the formatting), this is your directory layout within your document root (I've only shown the files important to this answer):
/home/index.php
/includes/header.php
/includes/footer.php
So, if you're in /home/index.php
, and you include 'header.php'
, PHP will assume that you're looking for the file located at /home/header.php
. What you need to do is tell PHP that you're looking in a different location.
In answer to your question, a good way of doing this is telling PHP to look relative to the current directory. This is how your includes would look afterwards:
include '../includes/header.php';
include '../includes/footer.php';
This basically tells PHP to go one level up from /home
(go into /
), enter into the includes
directory, and include the footer.php
or header.php
files.