variable_set

Definition

variable_set($name, $value)
includes/bootstrap.inc, line 631

Description

Set a persistent variable.

Parameters

$name The name of the variable to set.

$value The value to set. This can be any PHP data type; these functions take care of serialization as necessary.

Code

<?php
function variable_set($name, $value) {
  global $conf;

  db_merge('variable')->key(array('name' => $name))->fields(array('value' => serialize($value)))->execute();

  cache_clear_all('variables', 'cache');

  $conf[$name] = $value;
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.