Re: Re: Statics and PHP5
| From: | Adam Bregenzer | Date: | Tue, 17 Feb 2004 10:28:00 +0000 |
| Subject: | Re: Re: Statics and PHP5 | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-7917@lists.php.net to get a copy of this message | ||
On Tue, 2004-02-17 at 04:55, Stig S. Bakken wrote:
> Hi Dave,
>
> I think I see what you're saying. Static class variables are associated
> with the class, if the class persists between requests, so should its
> static variables.
[snip]
> All of these basically keep the parsed representation of code in shared
> memory between requests. It doesn't give you persistent class statics,
> but at least the request startup is much lower.
Great response, you saved me a lot of typing. :)
To add one thing, I have code that I use to easily persist an object
across a session, additionally it can save the class's static properties
(hacked into PHP4[1]). With this and my implementation of the singleton
pattern I am able to persist a singleton throughout a session. It's not
exactly what you are talking about but can be just as useful.
Additionally you can use a database or shared memory to implement global
variables and save objects/static variables/whatever into them. Of
course, once you have variables available to multiple instances of PHP
you will have to deal with locking issues.
Regards,
Adam
[1] http://adam.bregenzer.net/php/static_class_properties
--
Adam Bregenzer
adam@bregenzer.net
http://adam.bregenzer.net/