Tamer Zoubi @ Drupal 8


Drupal expert | Programmer

variable_set

variable_get and variable_set in Drupal 8

variable_get()/variable_set() and variable_del() API was removed from Drupal 8 in favor of Configuration API.

So in order to save a simple variable in your module firstly you need to decide on a config object name and a name for the settings. Simple settings can be stored in a config object named <module_name>.settings, while for more complex settings it is advisable to use sub-keys.

To get a variable in Drupal 7 you would use:

Tags
variable_get
variable_set
Drupal 8