PHP Include links

Renegade

New Member
Hello I'm having my first serious go with PHP to create a sample script for my self. It has a basic structure, in my root folder I have:
  • index.php
  • core folder (holds most of my php function files)
  • includes (holders my header.php and footer.php)
  • sites - (sites has 3 further folders site A, B, C)
  • CSS
  • js
All pages are made up by taking a header.php and footer.php from the includes folder and then each page has its own content in the middle. The header.php contains (as well as basic html and links to javascripts stylesheets ect) includes from core folder like so:
  • include_once '/core/connect.php';
Now these all work great using the index.php which provides links to the 3 different sections of the site, sitea, siteb and sitec.But when you navigate out of the document root to say /sites/sitea/index.php all those links are now broken.What is the best way to go about building the links in the header.php section so they are relative site wide no matter which folder you are in?
 
Back
Top