Reply to Re: Simple (?) Singleton Question

Your name:

Reply:


Posted by Michael Fesser on 11/14/07 17:07

..oO(Rob Wilkerson)

>> That's how singletons work in PHP.
>
>That's what I was afraid of. Kind of makes singletons worthless (at
>least for my case), doesn't it?

Partly. But they still assure that there's only a single instance to
work with, which is globally available from everywhere in your scripts.

>I could assign a new instance to a
>variable and just reference that variable through the life of the
>request. In the case of my (xml-based) config, I have to read the
>config on every single request. I was hoping to avoid that without
>using flat files or the session scope.

That's simply because of how PHP works:

init -> request -> response -> done
init -> request -> response -> done
....

To keep data available for several requests you would either need a real
application server:

init
request -> response
request -> response
....
done

which is not yet available for PHP (except for some experimental
projects) or you could have a look at shared memory.

Micha

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация