Skip to content
World Wide Web Server edited this page Jul 4, 2012 · 9 revisions

A simple PHP storage registry.

[strong]Download:[/strong] [url=https://github.com/alwarren/php.registry/zipball/master]https://github.com/alwarren/php.registry/zipball/master[/url]

[h2]Usage[/h2] [code] require_once 'registry.php'; [/code] [h3]As an Object[/h3] [code] // store a value $value = 'Hello World!' // mixed, can be anything $reg = new registry(); $reg->set('mykey', $value);

// retrieve a value
$myvar =  $reg->get('mykey');

[/code] [h3]As an Singleton[/h3] [code] // store a value $value = 'Hello World!' // mixed, can be anything registry::getInstance()->set('mykey', $value);

// retrieve a value
$myvar = registry::getInstance()->get('mykey');

[/code] [h3]Method Chaining[/h3] [code] // store a value $value1 = 'Hello World!' $value2 = "It's a great day." registry::getInstance() ->set('mykey1', $value1) ->set('mykey2', $value2) ; [/code] [h3]Query[/h3] [code] if registry::contains('mykey') { // do something } [/code]

Clone this wiki locally