Application Scope variables ?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tony Marston

    #31
    Re: Application Scope variables ?

    Then the answer is easy. Apache has no concept of an "applicatio n". It is simply a web server which waits for requests and issues responses. PHP also has no concept of an "applicatio n" 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

    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



    "aa" <aa@virgin.ne t> wrote in message news:41515c7c$0 $69739$ed2619ec @ptn-nntp-reader01.plus.n et...
    You missed me, Tony. Of course I did not mean application==we bserver
    "Tony Marston" <tony@NOSPAM.de mon.co.uk> wrote in message news:ciqd4r$o7m $1$830fa7a5@new s.demon.co.uk.. .
    If by "applicatio n" 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

    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



    "aa" <aa@virgin.ne t> wrote in message news:41508cf8$0 $17960$ed2619ec @ptn-nntp-reader02.plus.n et...
    "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.de mon.co.uk> wrote in message news:cipsgh$npr $1$8302bc10@new s.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

    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



    "aa" <aa@virgin.ne t> wrote in message news:415058ee$0 $42257$ed2e19e4 @ptn-nntp-reader04.plus.n et...
    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.ne t> wrote in message news:414eb86a$0 $80627$ed2619ec @ptn-nntp-reader01.plus.n et...
    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?

    Comment

    • Michael Fesser

      #32
      Re: Application Scope variables ?

      .oO(Tony Marston)
      [color=blue]
      >[...][/color]

      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

      Comment

      • aa

        #33
        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.de mon.co.uk> wrote in message news:cit5a1$2ov $1$8302bc10@new s.demon.co.uk.. .
        Then the answer is easy. Apache has no concept of an "applicatio n". It is simply a web server which waits for requests and issues responses. PHP also has no concept of an "applicatio n" 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

        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



        "aa" <aa@virgin.ne t> wrote in message news:41515c7c$0 $69739$ed2619ec @ptn-nntp-reader01.plus.n et...
        You missed me, Tony. Of course I did not mean application==we bserver
        "Tony Marston" <tony@NOSPAM.de mon.co.uk> wrote in message news:ciqd4r$o7m $1$830fa7a5@new s.demon.co.uk.. .
        If by "applicatio n" 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

        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



        "aa" <aa@virgin.ne t> wrote in message news:41508cf8$0 $17960$ed2619ec @ptn-nntp-reader02.plus.n et...
        "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.de mon.co.uk> wrote in message news:cipsgh$npr $1$8302bc10@new s.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

        This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL



        "aa" <aa@virgin.ne t> wrote in message news:415058ee$0 $42257$ed2e19e4 @ptn-nntp-reader04.plus.n et...
        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.ne t> wrote in message news:414eb86a$0 $80627$ed2619ec @ptn-nntp-reader01.plus.n et...
        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?

        Comment

        • Tony Marston

          #34
          Re: Application Scope variables ?


          "aa" <aa@virgin.ne t> wrote in message
          news:4152a0a2$0 $17948$ed2619ec @ptn-nntp-reader02.plus.n et...[color=blue]
          > 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.[/color]

          Correct. PHP does not understand the concept of "applicatio n" as you
          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

          This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL






          Comment

          Working...