I’m trying to introduce CI into a legacy application but want to use some of the globals that already exist externally from CI. I have been loading them into /CI/config/config.php and acquiring them using this in the view:
$this->config->item(‘myvar’);
That works fine. However, if I include my sidebar in the model called sidebar.php, which wants to access the globals stored in globals.php they come up as undefined. Note that sidebar.php uses a include statement to access globals from globals.php. Also, the globals are defined like this in globals.php:
$myvar = “bla”;
globals.php and sidebar.php are outside of CI. These two files don’t need to execute functions.
Does anyone know of a trick to allow CI and files it includes to access globals outside of it? I don’t want to change the legacy code too much.
It turns out I found an include_once statement for the globals.php file in a place where the legacy code couldn’t access it. The legacy code already had an include_once statement but it was ignored b/c it was already included elsewhere.
I assume that it’s acting similar to this in CI if I open testfile.php:
testfile.php:
sidebar.php