View Single Post
Old 10-11-2012, 02:37 PM   PM User | #1
Oatley
New Coder

 
Join Date: Sep 2012
Posts: 70
Thanks: 56
Thanked 0 Times in 0 Posts
Oatley is an unknown quantity at this point
Another question on the registry pattern?

Hello, before I was looking at the registry pattern and from what I read I can pass in values to store in an array as storage.

PHP Code:
$obj = new Registry();
$obj->set('anything''anyvalue'); 
However, I've just seen some examples whereby rather than using a set method to just pass in a key and a value as a string, it can pass in the 'new' keyword with a pre-defined class like

PHP Code:
$obj = new Registry();
$obj->set('anything', new ArrayIterator);
//or
$obj->set('anything', new stdClass); 
So using the registry class can you pass in only predefined classes? Or could I pass my own class I create in the registry pattern?

If you can pass in one of your own classes, how would you use it within the registry pattern? Does anyone have a basic example, or is it mainly used when passing in strings as per my first code example?

Thank you very much.
Oatley is offline   Reply With Quote