I have this code snippet that includes a subpage:
function getTabFile($pageName) {
if ($pageName == null)
return null;
if (preg_match("/^[a-z]+$/i", $pageName) != 1)
return null;
$fileName = getTabFileName($pageName);
if (file_exists($fileName))
return $fileName;
return null;
}
function getDefaultTabFile() {
return getTabFileName('default');
}
function getTabFileName($page) {
return __DIR__ . "/page/$page.php";
}
include (getTabFile($_GET['page'] ?? null) ?? getDefaultTabFile());
And I want this snippet itself to be included via:
$path = $_SERVER['DOCUMENT_ROOT'];
$path .= "/common/snippet.php";
include($path);
When I do this the script targets the relative DIR of where the snippet is located.
My question is: Is it possible to target the relative DIR of the file where the snippet is included?