sneskid Posted June 1, 2006 Share Posted June 1, 2006 if i use static variables in a class, will that only take effect for class instances within the current script, or will the value be accross all php script running at the same time which have included that class? Quote Link to comment https://forums.phpfreaks.com/topic/10984-static-variablesfunctions/ Share on other sites More sharing options...
trq Posted June 1, 2006 Share Posted June 1, 2006 If your users share one instance of a class (via a singleton pattern) the static variables will work as expected. Quote Link to comment https://forums.phpfreaks.com/topic/10984-static-variablesfunctions/#findComment-41035 Share on other sites More sharing options...
sneskid Posted June 4, 2006 Author Share Posted June 4, 2006 thats helpsbut my major question is how to allow php scripts running at the same time to share data.(say 10 people access the site at the same time)i could use a database to lug data back and forth, but there has to be an easier way Quote Link to comment https://forums.phpfreaks.com/topic/10984-static-variablesfunctions/#findComment-41750 Share on other sites More sharing options...
trq Posted June 4, 2006 Share Posted June 4, 2006 There is many ways of doing this, and really, it depends how much data there is and how often it maight change if at all.An easy option for minimal amounts of unchanging data is to just store it in variables and include this in each script that needs it.Another easy option and one which allows you to update the data more easily is to use a database / text files.Maybe another approuch would be to use a registry pattern? Like I say... It really depnds on the data. There is no such thing as an [i]application[/i] wide object in php, though you could easily create one. Quote Link to comment https://forums.phpfreaks.com/topic/10984-static-variablesfunctions/#findComment-41768 Share on other sites More sharing options...
sneskid Posted June 4, 2006 Author Share Posted June 4, 2006 I've considered the database/txt file options, and would like to avoid them if possible.Actually I don't mind the database way as much. But I need something with less overhead.It would be nice to just share data in memory through some kind of super global array. (in order to avoid reading from the HD every time)How would I go about setting up this application wide object. Quote Link to comment https://forums.phpfreaks.com/topic/10984-static-variablesfunctions/#findComment-41775 Share on other sites More sharing options...
trq Posted June 4, 2006 Share Posted June 4, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]How would I go about setting up this application wide object.[/quote]The easiest way would be to use the registry pattern. Im not sure how versed you are in OOP concepts but there is an article [a href=\"http://www.phppatterns.com/docs/design/the_registry\" target=\"_blank\"]here[/a] that might help you. Quote Link to comment https://forums.phpfreaks.com/topic/10984-static-variablesfunctions/#findComment-41881 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.