I was wondering, is there a way to have a sort of variable that would be ‘static’ meaning that it would be the same for all users in php ?
I know that there is a possibility to have a static variable within a function in php but that is not what I want.
I would like everyone to share an object which I would manipulate depending on the user’s demand.
Or, another example that is similar to what I want is, is there a way to keep a variable that counts the number of visitors (without using any sort of file or database manipulation). That variable would be incremented every time a user come to my page.
Cheers !
Without using a file or database, I believe you could do this using something like APC.
If you want to increment it, you can use
apc_inc()However, this variable won’t be preserved if the cache is cleared (which happens when it fills up or the server is restarted).