Ask a Question related to PHP Development, Design and Development.
-
Zurab Davitiani #21
Re: Application Scope variables ?
Lucas wrote:
Yes. Application level variables in this case means that the variables are> sessions are stored as common files on the web server, one can
> configure it accordingly to his/her needs so that data(variables) are
> accesible from the required scope. Is there anything I missed?
shared within the defined frame of an application. i.e. the variables are
shared between different sessions or clients accessing the "application."
For more information, look up Application and Session objects within the
ASP framework; or even Java servlets.
Zurab Davitiani Guest
-
Global Variables and scope
Ok, I'm creating a fairly large RIA using many components set on a page. They all share a common list. It is a Project list that is displayed in a... -
Initialize Server Scope Variables
We have a mix of ColdFusion servers running in a production or development mode. Some applications we have developed will send e-mails when running... -
DB Field name="application" and Application scope variables
Hi, There is DB Field application which overwrited ,as I see , Application scope variable Are there way to solve this problem without using... -
Application Scope
I have a farm of CF5 servers. In order to reduce the number of times I hit the database, I'm saving data within the application scope. I'm setting... -
Local Scope Variables
Hi, I'm having a bit of trouble with using some local scope variables. I have a function where I want to define a variable, then use that... -
aa #22
Re: Application Scope variables ?
You missed me, Tony. Of course I did not mean application==webserver
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:ciqd4r$o7m$1$830fa7a5@news.demon.co.uk...
If by "application" you mean "web server" then it is not common practice to stop the web server when the last client has finished. A web server usually runs 24/7 so that it is available whenever somebody wants to access it. If you are talking about a closed application such as on a company's intranet which may only be available during certain times of day then shutting down the web server does nothing more than shut down the web server. There is no concept of running any closedown routines for whatever application may have been accessed during the time the web server was running. A web server like Apache is merely a vehicle for servicing HTTP requests. It serves up html documents or php documents or whatever. Those documents are the application. It has no knowledge of any particular application which it may run. Why should it?
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:41508cf8$0$17960$ed2619ec@ptn-nntp-reader02.plus.net...
"There is no such thing as being able to detect when the application is closed.The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser?
That is impossible to tell."
That is not necessary to tell, for the actions of a particular visitor are not relevant.
As it happens with Windows/IIS/ASP, Application can either be closed manually, or it times out if there are not requests for a preset period of time. In other words, application closes when the last active session times out.
Is this the case with Apache server?
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:cipsgh$npr$1$8302bc10@news.demon.co.uk...
To implement a hit counter in PHP I would use a database table.
There is no such thing as being able to detect when the application is closed. The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser? That is impossible to tell.
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:415058ee$0$42257$ed2e19e4@ptn-nntp-reader04.plus.net...
Just to stream the discussion up - how a page hit conter in implemented in PHP?
In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
This variable is sitting in the memory as long as the Application (i.e. the website) is running.
If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.
How do I get the same effect in PHP?
"aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
Is there a similar mechanism in PHP?
aa Guest
-
Lucas #23
Re: Application Scope variables ?
Hi aa,
"aa" <aa@virgin.net> wrote in message news:<415055cf$0$42237$ed2e19e4@ptn-nntp-reader04.plus.net>...using real sessions(!=cookie emulation) makes it possible to access> Session will only make such a variable available within this session.
> But I am talking about a variable available from any page from any session
data from any client application, independent of the one that created
it. However, I did read some stuff on ALV, and admit it's much more
sophisticated, does anyone know if there are any improvements in PHP5?
>
> "Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message
> news:cip0pa$ig4$1$8300dec7@news.demon.co.uk...> retrieve> >
> > "aa" <aa@virgin.net> wrote in message
> > news:415002f7$0$42212$ed2e19e4@ptn-nntp-reader04.plus.net...> > > Thanks.
> > > You mean that PHP does not allow to store application-level variables in
> > > memory and every time I need to modify such a variable I have to> back> >> > > it
> > > from disc (a file or DB) and then to write it back?
> > If you want to store variables between one page and another the PHP way is
> > sessions. All you need is session_start() at the beginning of each script.
> > This will create an empty $_SESSION array the first time, then give you> as> > everything you put in it.
> >
> > Note that you do not have to write the session data out to file manually> using> > PHP will do it automatically for you at the end of the script. It's all in
> > the manual.
> >
> > --
> > Tony Marston
> >
> > [url]http://www.tonymarston.net[/url]
> >
> >
> >> > > "Zurab Davitiani" <agt@mindless.com> wrote in message
> > > news:ALJ3d.21759$Lf5.2677@newssvr27.news.prodigy.c om...
> > >> > your thinking is still too influenced by the rigid ASP structure.
> > >> > Relax, open your mind and RTFM on sessions. :-)
> > >>
> > >> Session variables are not the same as application-level variables. ASP
> > >> offers an application framework, ASP *is* the framework.
> > >>
> > >> Having said that, you can replicate functionality via PHP by either> info> > >> common files for variable storage/retrieval, or using a database. Some> >> > >> should be easily locatable by searching.
> > >
> > >
> >Lucas Guest
-
Tony Marston #24
Re: Application Scope variables ?
Then the answer is easy. Apache has no concept of an "application". It is simply a web server which waits for requests and issues responses. PHP also has no concept of an "application" in the way you describe for IIS/ASP. However, you can achieve the same functionality by using config files, sessions, and/or databases.
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:41515c7c$0$69739$ed2619ec@ptn-nntp-reader01.plus.net...
You missed me, Tony. Of course I did not mean application==webserver
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:ciqd4r$o7m$1$830fa7a5@news.demon.co.uk...
If by "application" you mean "web server" then it is not common practice to stop the web server when the last client has finished. A web server usually runs 24/7 so that it is available whenever somebody wants to access it. If you are talking about a closed application such as on a company's intranet which may only be available during certain times of day then shutting down the web server does nothing more than shut down the web server. There is no concept of running any closedown routines for whatever application may have been accessed during the time the web server was running. A web server like Apache is merely a vehicle for servicing HTTP requests. It serves up html documents or php documents or whatever. Those documents are the application. It has no knowledge of any particular application which it may run. Why should it?
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:41508cf8$0$17960$ed2619ec@ptn-nntp-reader02.plus.net...
"There is no such thing as being able to detect when the application is closed.The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser?
That is impossible to tell."
That is not necessary to tell, for the actions of a particular visitor are not relevant.
As it happens with Windows/IIS/ASP, Application can either be closed manually, or it times out if there are not requests for a preset period of time. In other words, application closes when the last active session times out.
Is this the case with Apache server?
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:cipsgh$npr$1$8302bc10@news.demon.co.uk...
To implement a hit counter in PHP I would use a database table.
There is no such thing as being able to detect when the application is closed. The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser? That is impossible to tell.
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:415058ee$0$42257$ed2e19e4@ptn-nntp-reader04.plus.net...
Just to stream the discussion up - how a page hit conter in implemented in PHP?
In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
This variable is sitting in the memory as long as the Application (i.e. the website) is running.
If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.
How do I get the same effect in PHP?
"aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
Is there a similar mechanism in PHP?
Tony Marston Guest
-
Michael Fesser #25
Re: Application Scope variables ?
.oO(Tony Marston)
Is it one of OE's many "features" to answer to an HTML-posting in HTML>[...]
instead of plain text?
It's not really funny having to download a bloated 305-lines posting
(thanks to the HTML) with just 4 lines of new text.
Fup2 poster
Micha
Michael Fesser Guest
-
aa #26
Re: Application Scope variables ?
In ASP an application is an object created when a first request is made to a website. This object seats in the memory and contains methods and properties 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 requestes for certain time (which can be preset on the websrver), the Application object is destroyed and memory reclaimed. Not to 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 before a relevant session expires.
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:cit5a1$2ov$1$8302bc10@news.demon.co.uk...
Then the answer is easy. Apache has no concept of an "application". It is simply a web server which waits for requests and issues responses. PHP also has no concept of an "application" in the way you describe for IIS/ASP. However, you can achieve the same functionality by using config files, sessions, and/or databases.
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:41515c7c$0$69739$ed2619ec@ptn-nntp-reader01.plus.net...
You missed me, Tony. Of course I did not mean application==webserver
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:ciqd4r$o7m$1$830fa7a5@news.demon.co.uk...
If by "application" you mean "web server" then it is not common practice to stop the web server when the last client has finished. A web server usually runs 24/7 so that it is available whenever somebody wants to access it. If you are talking about a closed application such as on a company's intranet which may only be available during certain times of day then shutting down the web server does nothing more than shut down the web server. There is no concept of running any closedown routines for whatever application may have been accessed during the time the web server was running. A web server like Apache is merely a vehicle for servicing HTTP requests. It serves up html documents or php documents or whatever. Those documents are the application. It has no knowledge of any particular application which it may run. Why should it?
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:41508cf8$0$17960$ed2619ec@ptn-nntp-reader02.plus.net...
"There is no such thing as being able to detect when the application is closed.The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser?
That is impossible to tell."
That is not necessary to tell, for the actions of a particular visitor are not relevant.
As it happens with Windows/IIS/ASP, Application can either be closed manually, or it times out if there are not requests for a preset period of time. In other words, application closes when the last active session times out.
Is this the case with Apache server?
"Tony Marston" <tony@NOSPAM.demon.co.uk> wrote in message news:cipsgh$npr$1$8302bc10@news.demon.co.uk...
To implement a hit counter in PHP I would use a database table.
There is no such thing as being able to detect when the application is closed. The client simply stops sending requests to your web site. Is he still reading the last page? Has he jumped to another site? Has he closed the browser? That is impossible to tell.
--
Tony Marston
[url]http://www.tonymarston.net[/url]
"aa" <aa@virgin.net> wrote in message news:415058ee$0$42257$ed2e19e4@ptn-nntp-reader04.plus.net...
Just to stream the discussion up - how a page hit conter in implemented in PHP?
In ASP you increment a relative Application scope variable every time a page is requested. This veraible is accessible from any session.
This variable is sitting in the memory as long as the Application (i.e. the website) is running.
If the Application is stopped, it fires an event "application_on_close" and on this event you write an application data to a file from which it can be recovered when the application is restarted.
How do I get the same effect in PHP?
"aa" <aa@virgin.net> wrote in message news:414eb86a$0$80627$ed2619ec@ptn-nntp-reader01.plus.net...
I am migrating to PHP from ASP where there are the Application Scope variables which are accessible from any page on a website and which are used, in particular, for hit counters.
Is there a similar mechanism in PHP?
aa Guest
-
Tony Marston #27
Re: Application Scope variables ?
"aa" <aa@virgin.net> wrote in message
news:4152a0a2$0$17948$ed2619ec@ptn-nntp-reader02.plus.net...Correct. PHP does not understand the concept of "application" as you> In ASP an application is an object created when a first request is made to
> a
> website. This object seats in the memory and contains methods and
> properties
> 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
> to
> 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
> before
> a relevant session expires.
describe it.
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
[url]http://www.tonymarston.net[/url]
Tony Marston Guest
-
Dave Ostrander #28
Application Scope variables ?
Basically, a well used application scope lets you use the Facade design pattern to share common functions and objects. Stuff you wouldn't want to initialize for every session.
For instance, if you have a set of objects that make PDF's for you, or read XML you could declare them in the Application variable to start on application start up. For a data access layer, where you have a class and objects for every one of your DB tables, initialization can take a while..
At least that's what i use the application scope for in other non PHP languages.Dave Ostrander Guest



Reply With Quote

