I have a scenario where I want to get a path back to a specific parent directory. Here is an example folder strcuture ([something] is a folder)
inde
You can use .. to get into the parent directory:
<?php
// somePage.php
include('../components/header.php');
?>
I would make sure that you always know the root of your site so that you can take it from there.
To do that, you could go at least two ways:
include MY_SITE_ROOT . '/path/to/file.php';include $_SERVER['DOCUMENT_ROOT'] . '/path/to/file.php';