Forum Moderators: coopster
Firstly i remember reading a PDF a while ago the explained the ins and outs of how arrays were handled inside PHP, and what happens to registrars and memory when an array is popped, pushed, copied and referenced. I can't for the life of me remember where i read this but if anyone has a clue of what I'm talking about i would be delighted if you could post a link!
Ok, the question. I have a registry class, a singleton that is instantiated once and used by all other classes. the registry has methods that allow add to, select and remove data to a property that is an array.
I have a second class, say "class A", that adds information to the registry.
Now i have another class: "class B", method that when a specific method is run it obtains information from the data property in the registry and processes it. This method requires information relating to a specific object that's created from class A.
My question is which is the better/right/correct/efficient way of doing this? should i:
a) Obtain a auto-incremental id of the data in the registry, and pass that id to class B, so the method looks in the registry to find the data?
b) Send the object to class B's method, so that it has immediate access to the data - and all other public properties?
c) something else more efficient?
It would be great to hear some insight on how PHP handles this stuff, and what would be the most memory efficient way of achieving this.
Thank you.