php - Creating variables using $GLOBALS -


I am currently working on a php framework, in some cases, such as ZendFramework. I did not find any matching matches with my problem.

My "problem" I have a variable number of classes (model, controller), e.g. Http_handler Now I have many such classes, which I can not set all of these manuals in variables.

Can I use $ globals for $ variableVar?

  foreach ($ classes as $ square) {include_once ($ square. '.php'); $ Global [$ square] = new $ square; }  

Is this a new variable that will be accessible through the entire code? Example:

  // ... Code $ http_handler-> Send request ($ someArgs); // ... code  

this will happen, but you have to import the global variable In the field of method:

  function fu () {global $ http_handler;  

Although there are better solutions for this. See for example

I used a singleton pattern to ask a question about how to organize all these classes recently, maybe some answers give you additional thought:


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -