I have a list of files that I require_once at the beginning of my main scripts.
In one of those files, I have a bunch of functions.
In another one of those files, I have a bunch of constants (which are variables at the moment, but they are essentially constants).
Main.php
require_once \Constants.php
require_once \Functions.php
From within main.php, I am able to call functions and call the constants from their respective scripts... I am also able to call functions and pass the constants from Constants.php as parameters to the functions.
However, I am not able to use functions that have the constants embedded within them.
In other words, I cannot use the functions from Functions.php that already have the variables from the Constants.php file within the functions, but I am able to use functions from Functions.php if they do not have any variables from other included files within the function.
Function FirstFunction(){ echo $Constant1; return 1 }
FirstFunction() uses $Constant1 from Constants.php and does not work.
Function SecondFunction($param){ echo $param; return 1 }
SecondFunction() can be passed $Constant1 from Constants.php as a parameter and it works fine.
Questions:
Is there a way for me be able to use my Main.php to call a function file and a constant file and have the function file use variables from the constant file without explicitly calling or passing them from within Main.php?
If I were to daisy chain them (Main.php calls Functions.php; Functions.php calls Constants.php) will this work? (I kind of tried this but not well enough to either trust or rule out this method just yet).
Note
Most of the information I am able to find is regarding using variables from included files, but not specifically about included files using variables from other included files.