OK, the title is a little confusing but this is the structure of my web site:
/
|--header.php
|--page1.php
+--css
|--style.css
+--subsection
|--page2.php
+--functions
|--classes.php
Right, so both page1.php and page2.php will include header.php. This I do by just using the relative file path from whatever php page to the header.php.
header.php itself includes other files; for example css/style.css and functions/classes.php.
I might include them like the following:
<link rel="stylesheet" href="css/style.css">
<?php require_once("functions/classes.php"); ?>
This will work for page1.php as the reletive paths are correct. For subsection/page2.php this will fail as the paths should be ../css/style.css and ../functions/classes.php but remain as they are defined in header.php.
My question is how can I get header.php to always use the correct relative file paths for its includes regardless of where the file calling header.php (e.g. apage.php) is located in the web site directory.