I have a dilemma over the include function. My code structure is simplified to what you see below. Main.php needs $constVar, which is stored inside constants.php. Main calls page.php. Page also needs $constVar, so it must include it again. I run into errors of variable redefinition. When I attempt to use include_once(), only either main or page gets to use $constVar.
<?php
// main.php
include("constants.php");
echo($constVar);
include("page.php");
pageCode();
?>
<?php
// page.php
function pageCode()
{
include("constants.php");
echo($constVar);
}
?>
<?php
// constants.php
$constVar = 5;
?>