![]() |
site wide globals() function - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Libraries & Helpers (https://forum.codeigniter.com/forumdisplay.php?fid=22) +--- Thread: site wide globals() function (/showthread.php?tid=20498) |
site wide globals() function - El Forum - 07-12-2009 [eluser]ntheorist[/eluser] Here's a little function i'm playing with for storing and retrieving global data for use in views and elsewhere within an application. The point of course isn't to store vast amounts of data, just to collect basic variables in one place, preferences, config, userdata, uri variables etc. The reason i want to use a function instead of using $this->load->vars($array) is mainly to avoid name conflicts within views, but also so i can set vars within constructors and use them in methods/libraries/plugins as well. it's use is pretty basic too: Code: globals('test','123'); // Set test to 123 Here it is. Comments, suggestions, criticisms welcome. Code: if ( ! function_exists('globals') ) n |