Hi:
PHP5. If I create a class with a static member property (variable) and I use value of that property during the execution of a script what happens if other requests are made for the same script? If I were instantiating an object, each instance could be changed independently without affecting the others. But what if it's a static variable?
If I have multiple HTTP requests for the same script, and the variable is changed in each, will changes in one affect the other?
??
Please advise.
THANKS MUCH!
Life and scope of static member properties
Moderator: General Moderators
-
Mark Baker
- Forum Regular
- Posts: 710
- Joined: Thu Oct 30, 2008 6:24 pm
Re: Life and scope of static member properties
Individual http request are running in their own thread, so changes made to a static property by one will not affect any of the other threads. Changing a static property within a thread will affect any subsequent access to that proprty within that individual thread
Re: Life and scope of static member properties
Mark:
Thank you. I suspected as much, and that was certainly the answer I wanted to hear, but it's good to get confirmation from someone with more experience!
Regards,
-cbc
Thank you. I suspected as much, and that was certainly the answer I wanted to hear, but it's good to get confirmation from someone with more experience!
Regards,
-cbc