I'd like to create a global variable (in PHP) to store the value of a submitted field so that (the global variable) is available to all the visitors of my site. Its something like "Application Variable" in ASP, but I wonder how to do it in PHP.
I don't want to use database.
I know that in ASP we use Application Variable whch is Global, it means it stores the data and make it available to all the visitors who visits the site. And preserve the data(variables) until the system reboots. Has anyone have an idea how to do it in PHP.
I want to know how can we use Application Variable in PHP to store the data which is gobally accessible to all the visitors. And please remember I don't want to use Database, so please don't give a suggestion of using database.
Thanks.
Want to know Application Variable in PHP
Moderator: General Moderators
Another option is to store it in memory. The Turck MMCache accellerator provides an API for storing data in memory. It's a good deal faster than getting the info from off a disk or out of a database.
However, what do you do when the site starts growing and you find yourself needing a web farm? Unless someone comes out with a method of storing application vars (memory or file based) consistently across a load balanced cluster, a database is your best bet.
Cheers,
BDKR
However, what do you do when the site starts growing and you find yourself needing a web farm? Unless someone comes out with a method of storing application vars (memory or file based) consistently across a load balanced cluster, a database is your best bet.
Cheers,
BDKR
Just thought I'd post the API...
Turck MMCache API
mmcache_put($key, $value, $ttl=0)
puts the $value into shard memory for $ttl seconds.
mmcache_get($key)
returns the value from shared memory which was stored by mmcache_put() or null if it is not exists or was expired.
mmcache_rm($key)
removres the $key from shared memory
mmcache_gc()
removes all expired keys from shared memory
mmcache_lock($lock)
creates a lock with specified name. The lock can be released by function mmcache_unlock() or automatic on the end of request. For Example:
<?php
mmcache_lock("count");
mmcache_put("count",mmcache_get("count")+1));
?>
mmcache_unlock($lock)
release lock with specified name
The site is
http://turck-mmcache.sourceforge.net/
Cheers,
BDKR
Turck MMCache API
mmcache_put($key, $value, $ttl=0)
puts the $value into shard memory for $ttl seconds.
mmcache_get($key)
returns the value from shared memory which was stored by mmcache_put() or null if it is not exists or was expired.
mmcache_rm($key)
removres the $key from shared memory
mmcache_gc()
removes all expired keys from shared memory
mmcache_lock($lock)
creates a lock with specified name. The lock can be released by function mmcache_unlock() or automatic on the end of request. For Example:
<?php
mmcache_lock("count");
mmcache_put("count",mmcache_get("count")+1));
?>
mmcache_unlock($lock)
release lock with specified name
The site is
http://turck-mmcache.sourceforge.net/
Cheers,
BDKR