I've got a handful of variables that I need access to in more functions than I initially thought.
What would be the best way of including them in my growing list of functions?
I've got something like
$site = 'a';
$admin = 'b';
$dir = 'c';
$ma_plug = 'd';
$base = 'e';
//Etc.
I need almost all of those in a large handful of my functions. I was initially doing
function a(){
global $site, $admin, $dir, $ma_plug, $base;
//Write the A function
}
function b(){
global $site, $admin, $dir, $ma_plug, $base;
//Write the B function
}
That was great, until I realized I've got more functions to write than I initially thought.
What would be the best way to get all those variables into the scope of (almost) each function? Like I've done? Or something like using Constants? I'd like to avoid using session() if at all possible
$this->. Constants are good, but can not be edited afterwards. If you're adding a variable which is constant (does not change), and has to be available in the global scope, use constants. Please use constants WRITTEN_LIKE_THIS for readability of your own code, as they're much easier to spot.