You are here

Module variable new

Start using Module variable by creating an object from class module_variable. Your module supplies the name of your module, the lower case machine name, not a decorative title. In this example we are adding variables to a module named Translate Java to PHP. The internal name, the name used for the first part of the name for the .info, is kill_java. The Module variable class, named module_variable, is loaded automatically by Drupal 7 when you use the class. The following code creates a Module variable object named $mv from class module_variable. The only information needed is the name of your module.
$mv = new module_variable('kill_java');
The following code displays the created object.
var_dump($mv);
Here is the result. You can see the module name is stored in the object along with a place for the variables.
object(module_variable)#90 (2) {
  ["module_name":"module_variable":private]=>
  string(9) "kill_java"
  ["variables":"module_variable":private]=>
  array(0) {
  }
}