function variable_set

Sets a persistent variable.

Case-sensitivity of the variable_* functions depends on the database collation used. To avoid problems, always use lower case for persistent variable names.

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.

See also

variable_del()

variable_get()

57 calls to variable_set()
BreadcrumbTest::testBreadCrumbs in drupal/core/modules/system/lib/Drupal/system/Tests/Menu/BreadcrumbTest.php
Tests breadcrumbs on node and administrative paths.
CacheDecoratorLanguageTest::setUp in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php
Sets up a Drupal site for running functional and integration tests.
CacheDecoratorLanguageTest::testCacheDecoratorLanguage in drupal/core/modules/system/lib/Drupal/system/Tests/Plugin/CacheDecoratorLanguageTest.php
Check the translations of the cached plugin definitions.
CommentLinksTest::setEnvironment in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentLinksTest.php
Re-configures the environment, module settings, and user permissions.
CommentTestBase::setCommentSettings in drupal/core/modules/comment/lib/Drupal/comment/Tests/CommentTestBase.php
Sets a comment settings variable for the article content type.

... See full list

File

drupal/core/includes/bootstrap.inc, line 919
Functions that need to be loaded on every Drupal request.

Code

function variable_set($name, $value) {
  global $conf;
  db_merge('variable')
    ->key(array(
    'name' => $name,
  ))
    ->fields(array(
    'value' => serialize($value),
  ))
    ->execute();
  cache('bootstrap')
    ->delete('variables');
  $conf[$name] = $value;
}