One way of doing this is by adding a function to a helper file that you make available globally.
I have a helper file application/helpers/main_helper.php in which I load a number of generic, common functions which are used throughout my application.
If you add the following function to the main_helper file:
/*
|--------------------------------------------------------------------------
| Function to retrieve Static Variables used Globally
|--------------------------------------------------------------------------
*/
function get_var($var = 'CONFIDENCEVALUE', $KEY = NULL) {
$r = false;
switch ($var) {
case 'CONFIDENCEVALUE':
$r = array('1'=>25,'2'=>'60','3'=>80,'4'=>100);
if($KEY !== NULL) $r = $r[$KEY];
break;
}
return $r;
}
This file is auto-loaded by editing the file application/config/autoload.php and editing the line:
$autoload['helper'] = array('main_helper');
Whenever this array (or a value from the array) is needed, call the function instead. eg.:
$CONFIDENCE = get_var('CONFIDENCEVALUE', 2);
If you include the $KEY when calling get_var(), then only the value is returned, otherwise the whole array is returned.
To make additional variables available, just add them to the switch and call them as needed.
Feedback welcome :).