473,583 Members | 2,875 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Application Scope variables ?

aa
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?

Jul 17 '05 #1
33 15855
aa wrote:
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?


Hi,

Yes there is, take a look at sessions:
http://nl3.php.net/manual/en/ref.session.php

Regards,
Ruben.
Jul 17 '05 #2
Dear Virgil,

your thinking is still too influenced by the rigid ASP structure.
Relax, open your mind and RTFM on sessions. :-)
Best Regards,

Lucas

"Virgil Green" <vj*@DESPAMobsy dian.com> wrote in message news:<Cn******* ***********@new ssvr30.news.pro digy.com>...
"Ruben van Engelenburg" <ruben@NOSPAM!. nl> wrote in message
news:41******** *************** @news.xs4all.nl ...
aa wrote:
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?


Hi,

Yes there is, take a look at sessions:
http://nl3.php.net/manual/en/ref.session.php


Sessions are not the same as application scope, I don't believe.

I've seen references to shared memory schemes, but they are avaialble to the
entire computer, not just a single application (all sessions running under
the same site id, for example).

- Virgil

Jul 17 '05 #3
> 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 using
common files for variable storage/retrieval, or using a database. Some info
should be easily locatable by searching.
Jul 17 '05 #4
aa
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 retrieve it
from disc (a file or DB) and then to write it back?

"Zurab Davitiani" <ag*@mindless.c om> wrote in message
news:AL******** **********@news svr27.news.prod igy.com...
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 using
common files for variable storage/retrieval, or using a database. Some

info should be easily locatable by searching.

Jul 17 '05 #5

"aa" <aa@virgin.ne t> wrote in message
news:41******** *************** @ptn-nntp-reader04.plus.n et...
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 retrieve
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 back
everything you put in it.

Note that you do not have to write the session data out to file manually as
PHP will do it automatically for you at the end of the script. It's all in
the manual.

--
Tony Marston

http://www.tonymarston.net
"Zurab Davitiani" <ag*@mindless.c om> wrote in message
news:AL******** **********@news svr27.news.prod igy.com...
> 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 using
common files for variable storage/retrieval, or using a database. Some

info
should be easily locatable by searching.


Jul 17 '05 #6
aa wrote:
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 retrieve it
from disc (a file or DB) and then to write it back?


That's the case. However I've found from experience that the only real
application globals needed are configuration parameters. These are
probably best loaded from a flat file as the application shouldn't be
changing them in the first place. Including a config file is fairly low
overhead in php.

If you need global variables then the simplest method is to save them in
a DB table. The overhead of retrieving these should be minimal as DB
servers should cache regular queries.
Jul 17 '05 #7
Dear Zurab,

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?
Best Regards,

Lucas
Zurab Davitiani <ag*@mindless.c om> wrote in message news:<AL******* ***********@new ssvr27.news.pro digy.com>...
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 using
common files for variable storage/retrieval, or using a database. Some info
should be easily locatable by searching.

Jul 17 '05 #8
"Lucas" <th******@direc tbox.com> wrote in message
news:fd******** *************** **@posting.goog le.com...
Dear Virgil,

your thinking is still too influenced by the rigid ASP structure.
Relax, open your mind and RTFM on sessions. :-)


I'm hardly influenced by ASP structure. I've never worked in ASP. I've read
the PHP manual sections on sessions many times before.

Please, enlighten me. Explain to me how sessions could be used to provide
the equivalent of application-scoped variables in ASP. The closest thing I
see is by sharing session IDs. That, of course, is a hack. There would be
nothing by default to synchronize access between multiple requests, so each
request could start with the same session info, update it and then spend
time merrily writing over each others changes. I could write my own custom
save handler, but I believe that writing such a handler to manage multiple
sessions as a single "session" would violate the spirit of the session and
lead to a maintenance nightmare.

I look forward to the details of your strategy.

- Virgil
Jul 17 '05 #9
aa
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

"Tony Marston" <to**@NOSPAM.de mon.co.uk> wrote in message
news:ci******** ***********@new s.demon.co.uk.. .

"aa" <aa@virgin.ne t> wrote in message
news:41******** *************** @ptn-nntp-reader04.plus.n et...
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 retrieve 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

back everything you put in it.

Note that you do not have to write the session data out to file manually as PHP will do it automatically for you at the end of the script. It's all in
the manual.

--
Tony Marston

http://www.tonymarston.net
"Zurab Davitiani" <ag*@mindless.c om> wrote in message
news:AL******** **********@news svr27.news.prod igy.com...
> 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 using common files for variable storage/retrieval, or using a database. Some

info
should be easily locatable by searching.



Jul 17 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2203
by: Hal Vaughan | last post by:
Being self taught, this is one thing I've always had trouble with -- I finally get it straight in one situation and I find I'm not sure about another. I have a class that keeps calling an internal method. If I define variables within the method, I would expect that they're new and clean each time I call the method. If I'm calling from...
4
3527
by: BB | last post by:
Hello all, I might be missing something here, but am trying to understand the difference between using application-level variables--i.e. Application("MyVar")--and global variables--i.e. public myVar as string, etc. It seems to me that the scope and duration are the same, as they both are there while the application is running, and both go away...
20
4440
by: J-T | last post by:
We are working on an asp.net application which is a 3-tier application.I was aksed to create a component which monitors a folder and gets the file and pass them to a class library in our business logic layer(so far so good and easy).I initialize my class which is using a FileSystemWatcher in my Global.asax and everything works fine.I have...
7
2103
by: WXS | last post by:
Vote for this idea if you like it here: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=5fee280d-085e-4fe2-af35-254fbbe96ee9 ----------------------------------------------------------------------------- This is a consortium of ideas from another thread on topic...
3
4147
by: rdemyan via AccessMonster.com | last post by:
Sometimes users (including myself) accidentally click on the application close icon in the application menu bar when they meant to just click on the 'X' for the form. Of course the app closes and this is very annoying. So, I added a messagebox to my hidden StartAppForm in the Unload event. Now when the application closes the user is...
0
1713
by: ellon | last post by:
I found a good way to do that: <?php function application_start (){ global $_APP; global $shm_id; $shm_id = shmop_open(0xff3, "c", 0644, 10000); $shm_size = shmop_size($shm_id); $data = shmop_read($shm_id, 0, $shm_size); $_APP=$_APP = unserialize($data); }
11
2340
by: Sylvia A. | last post by:
How can I define global classes in web application ? Classes can be set to session variables ? Thanks
1
25646
pbmods
by: pbmods | last post by:
VARIABLE SCOPE IN JAVASCRIPT LEVEL: BEGINNER/INTERMEDIATE (INTERMEDIATE STUFF IN ) PREREQS: VARIABLES First off, what the heck is 'scope' (the kind that doesn't help kill the germs that cause bad breath)? Scope describes the context in which a variable can be used. For example, if a variable's scope is a certain function, then that...
0
35199
MMcCarthy
by: MMcCarthy | last post by:
We often get questions on this site that refer to the scope of variables and where and how they are declared. This tutorial is intended to cover the basics of variable scope in VBA for MS Access. For the sake of brevity I am sticking to common usage. Wherever the term procedure is used in this tutorial it actually refers to a subroutine or...
0
7811
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8314
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7922
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8185
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6571
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
3811
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3836
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2317
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1416
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.