Saving variables on server in php
Is there a way, in php, t开发者_开发百科o save a variable on server so it stay there for all of the requests (not session, need to be saved for all users ever)? i'm new in php, in asp.net is use the 'application' context.
thanks.
PHP does not have an application context, probably because of it's script nature. You may store data for an user and for a limited period if time in the session, but if you want something per application you should implement it yourself. Storing in a database would be best. By using a class that implements ArrayAccess you will replicate an application context.
If you want some sort of fast access to you data you could use Memcache. But that is not really application data. It's just caching. That means you have to have a fallback to something (database) if the data you want is no longer found in the cache.
So if you want a fast and reliable way to store application data in PHP you should do it with a database table for storing it and Memcache for fast access.
Yes, it's called session.
look at $_SESSION
variable ;-)
精彩评论