Re: Application Scope variables ?
From: Tony Marston (tony_at_NOSPAM.demon.co.uk)
Date: Thu, 23 Sep 2004 18:49:53 +0100
"aa" <firstname.lastname@example.org> wrote in message
> In ASP an application is an object created when a first request is made to
> website. This object seats in the memory and contains methods and
> some of the properties can be created and modified from ASP code.
> As a websever can serve more them one website and some websites might be
> visited just several times a day, there is little point to keep all these
> website objects in the memory all the time. For that purpose, if a website
> does not receive requests for certain time (which can be preset on the
> websrver), the Application object is destroyed and memory reclaimed. Not
> loose data stored in the Object, it allows to write this data onto disk
> before being destroyed.
> If I understand correctly, PHP does not maintain such an object and the
> variables relevant to the whole website need to be written onto disk
> a relevant session expires.
Correct. PHP does not understand the concept of "application" as you
>From your description it seems to be more of a function of the web server as
only the web server can create the object on the first request, and destroy
the object if there have not been any requests for a period of time.
If you want to emulate this with PHP you must read in the variables with
every request and write out any changes before the script dies. You can use
session files or database tables. It may be possible to use data in shared
memory, but you would have to write your own routines for loading it and
destroying it. Personally I wouldn't bother as the overhead of reading in
data with every request is so small that it's not worth the effort to
replace it with something more flashy.
-- Tony Marston http://www.tonymarston.net