I'm building a website that consists of several php files that are included in the index.php file.
My index.php file:
<body>
<!-- include header -->
<?php include "./includes/header.inc.php"; ?>
<!-- include sidebar -->
<?php include "./includes/sidebar.inc.php"; ?>
<!-- include the content -->
<?
$page = $_GET['p'];
$includePage = "./pages/$page.php";
if ($page)
{
if ( file_exists($includePage) )
{
include $includePage;
}
else
{
include "./pages/404.php";
}
}
else
{
include "./pages/home.php";
}
?>
<!-- include footer -->
<?php include "./includes/footer.inc.php"; ?>
</div>
</body>
My header.inc.php includes a breadcrumbs feature that tracks the user's progress throughout the website. The included content page contains a variable titled $breadcrumb that contains the breadcrumbs to displayed in the header.
My problem is that the header.inc.php is included before the content page, so the header.inc.php file never sees the $breadcrumb variable (because it hasn't been declared/included yet).
Is there any way to have the header.inc.php get the $breadcrumb variable from the content page before it is included? I've tried including the content page before the header, but that also displays the content inside the header.
Any help would be greatly appreciated!