JRegistry/getInstance
From Joomla! Documentation
< API16:JRegistry
The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.
Description[edit]
Returns a reference to a global JRegistry object, only creating it if it doesn't already exist.
Syntax[edit]
static getInstance($id, $namespace= '_default')
Parameter Name | Default Value | Description |
---|---|---|
$id | An ID for the registry instance | |
$namespace | '_default' | The default namespace for the registry object [optional] |
Returns[edit]
object The object.
Defined in[edit]
libraries/joomla/registry/registry.php
Importing[edit]
jimport( 'joomla.registry.registry' );
Source Body[edit]
public static function getInstance($id, $namespace = '_default')
{
static $instances;
if (!isset ($instances)) {
$instances = array ();
}
if (empty ($instances[$id])) {
$instances[$id] = new JRegistry($namespace);
}
return $instances[$id];
}
Examples[edit]
Code Examples[edit]