| 
	
 | 
 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] 
 |