Re: -> PHP4 Singleton implementation question <-
- From: Jerry Stuckle <jstucklex@xxxxxxxxxxxxx>
- Date: Thu, 30 Nov 2006 11:13:24 -0500
Steve JORDI wrote:
Following the PHP documentation on http://nl3.php.net/static , I would suggest to replace this last line with a non-referencing one:
$welcome = Welcome::getInstance() ;
Did this but it din't change a thing.
As was posted earlier, PHP5 has solved the objects-and-references problem.
Yes, but I have to deal with PHP4, not 5 unfortunately.
I also tried to set a $_SESSION['welcome'] variable, but still, each
time I reenter my page, it's reassigned a new instance.
It's crazy, I would never have thought that it would be such a hassle
to keep a variable value between pages (without using URL parameters).
Thanks anyway.
Sincerely,
Steve JORDI
(Remove the K_I_L_LSPAM from my email address)
------------------------------------------------
1197 Prangins Email: stevejordiK_I_L_LSPAM@xxxxxxxxxxx
Switzerland WWW: www.sjordi.com
------------------------------------------------
Volcanoes at www.sjordi.com/volcanoes
MovieDB at www.sjmoviedb.com
------------------------------------------------
Steve,
If you've ever done any transactional processing, that's what web pages are.
When the browser makes a request, the server starts a process (or thread) to handle the request. It allocates the necessary resources, and turns control over to your program (the php interpreter, in this case). The interpreter allocates additional resources as necessary to process your script and runs the script.
When the script ends, the process reverses. The interpreter cleans up its resources and returns to the server. The server then cleans up the resources it allocated and terminates the process or thread.
Each request is separate in itself. Resources are not kept, because another request may or may not follow this one. And if another request does come in, it may or may not be something you expect. And it may or may not be from the same user.
Now, the developers understood there was a need to save information across requests. Therefore they implemented sessions to save the data on the server, and cookies to save it on the browser.
So, if you want to save your object across the request, you need to store it in the session (not a good idea to store this in the cookie - too many people have cookies disabled, and saving them on the user's computer allows the user to edit the cookie).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@xxxxxxxxxxxxx
==================
.
- Follow-Ups:
- Re: -> PHP4 Singleton implementation question <-
- From: Steve JORDI
- Re: -> PHP4 Singleton implementation question <-
- References:
- -> PHP4 Singleton implementation question <-
- From: Steve JORDI
- Re: -> PHP4 Singleton implementation question <-
- From: Dikkie Dik
- Re: -> PHP4 Singleton implementation question <-
- From: Steve JORDI
- -> PHP4 Singleton implementation question <-
- Prev by Date: Re: Trimming a large log file?
- Next by Date: ezPDF Question
- Previous by thread: session (was: -> PHP4 Singleton implementation question <-)
- Next by thread: Re: -> PHP4 Singleton implementation question <-
- Index(es):