I'm in my modular file. I want to define some complex variables for use throughout the module. For simple things, I do this:
function mymodule_init() { define('SOME_CONSTANT', 'foo bar'); }
But this will not work for more complex structures. Here are some ideas that I thought of:
global:
function mymodule_init() { $GLOBALS['mymodule_var'] = array('foo' => 'bar'); }
variable_set:
function mymodule_init() { variable_set('mymodule_var', array('foo' => 'bar')); }
module class property:
class MyModule { static $var = array('foo' => 'bar'); }
Variable_set / _get seems to be the most "drupal" way, but I'm drawn to setting up the class. Are there any flaws? Are there any other approaches?
source share