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
423 calls to variable_set()
- AccessDeniedTestCase::testAccessDenied in modules/
system/ system.test - ActionLoopTestCase::testActionLoop in modules/
simpletest/ tests/ actions.test - Set up a loop with 3 - 12 recursions, and see if it aborts properly.
- AggregatorRenderingTestCase::testFeedPage in modules/
aggregator/ aggregator.test - Creates a feed and checks that feed's page.
- aggregator_update_7001 in modules/
aggregator/ aggregator.install - Add aggregator teaser length to settings from old global default teaser length
- AJAXFormPageCacheTestCase::setUp in modules/
simpletest/ tests/ ajax.test - Sets up a Drupal site for running functional and integration tests.
File
-
includes/
bootstrap.inc, line 1310
Code
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_bootstrap');
$conf[$name] = $value;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.