Will a Registry Class in PHP work like this? -


If I create a registry object to store other objects and settings like this ...

  $ Registry = Registry :: getInstance ();  

And then create 2 other objects and pass them to the registry object as follows ...

  $ core = new core ($ registry) ; $ Database = Database :: getInstance ($ Registry);  

And then in the script I add some objects to the registry object ...

  // Some objects in our object are stored in the registry object Pattern $ Registry-> Store object ("database", $ databases); $ Registry- & gt; Store object ("session", $ session); $ Registry- & gt; Store object ("cache", $ cache); $ Registry- & gt; Store object ("user", $ user);  

In the main and database objects created at the top, the methods can still have access to all the objects, which I store in the registry, even if other ozages are stored in the registry. Database Objects were Created?

Yes, they will pass the objects reference (php> = 5), then each variable has the same built-in You will see the object.

In the old PHP, you have to pass by the referee:

  $ obj-> Registry = & amp; $ Registry; Function F (& amp; $ Registry)) {// $ Registry is a reference}  

key in php & lt; 5 ampersands syntax is specified when and in function declarations.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -