You are here: Re: PHP static scope « PHP Programming Language « IT news, forums, messages
Re: PHP static scope

Posted by ks on 01/23/06 22:46

Thanks,
I'm coming from an ASP.NET background where the use of static is more
traditional (or atleast, independent of web paradigms). In ASP.NET it
can obviously lead to considerably thread-safety issues if improperly
used.

I'll simply design my solution differently :)

Thanks for the help,
Karl

ZeldorBlat wrote:
> You're misunderstanding how this is supposed to work. Forget, for a
> moment, about sessions, cookies, get and post. So, when the user
> requests a page, PHP fires up, runs the PHP code and outputs HTML to
> the browser. That script is done. No more. Not coming back.
> Anything done on that page is "forgotten" before the next request.
>
> Put another way, each request is independent. So, your observation
> that "If I call Instance twice within the same request, the singleton
> works" is correct, and is the expected behavior.
>
> If you want things to persist between requests (or be shared among many
> requests) you'll need to save that state somehow. This is the intended
> use of sessions, cookies, get and post. If you want to share something
> among many requests then you're looking at something like a database or
> shared memory.

 

Navigation:

[Reply to this 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

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