1 bootstrap.inc | state_get($name, $default = NULL) |
Retrieves a "state" value from the database.
States are used for saving long-term values in the database that are environment-specific. Some examples of values appropriate for utilizing states include the last time cron was run or the current query string appended to CSS/JS files. These values should not be copied between environments, so they are stored in the state system instead of as configuration files.
Case-sensitivity of the state_* functions depends on the database collation used. To avoid problems, always use lower case for persistent state names.
Parameters
$name: The name of the state to return.
$default: The default value to use if this state has never been set.
Return value
The value of the state. Complex data types such as objects and arrays are: unserialized when returned.
See also
File
- core/
includes/ bootstrap.inc, line 1398 - Functions that need to be loaded on every Backdrop request.
Code
function state_get($name, $default = NULL) {
$states = &backdrop_static('states');
if (!isset($states)) {
$states = state_initialize();
}
return isset($states[$name]) ? $states[$name] : $default;
}