# [Proposal] Idea for Application level variables

- Thread: https://externals.io/message/3805
- Original archive: https://news-web.php.net/php.internals/3805
- Started by Jeremy S. Johnstone on 2003-08-07T16:33:19+00:00
- Messages: 2
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #3805 — Jeremy S. Johnstone — 2003-08-07T16:33:19+00:00

URL: https://externals.io/message/3805#3805

I noticed something which you said, and forgive me if this part may be
obvious, but you mentioned across instances of applications? Do you mean
something like a shared memory between all web connections to the
server? One issue I could forsee if this is the case, what happens when
there is no connections to the server for an extended period of time
(extended being even as short as a few minutes)? Should PHP store this
superglobal's value indefinitely, or perform some type of garbage
collection? If PHP should clean up after itself, what criteria would you
expect to be followed for deciding if something is no longer useful? I
don't think you would want this criteria configurable in a ini setting
for example, because hosting companies all do something different. If a
developer were to use this feature, they would need a standardized
timeframe that the values would last. This is just a couple things I
think would need to be considered before implementing something like
this. If I am way out in left field, I apologize.

-Jeremy

-----Original Message-----
From: Davey [mailto:davey@php.net] 
Sent: Thursday, August 07, 2003 8:15 AM
To: internals@lists.php.net
Subject: Re: [PHP-DEV] [Proposal] Idea for Application level variables


Andrey,

 > // masv = my application shared vars. This is the name of the shared
var.  > // Only the first 4 chars are used to calculate memory address.
> $_APPLICATION = new Shm_Protected_Var("masv", 1024 /*memory*/);  >
$_APPLICATION->start_section()  > var_dump($_APPLICATION->getVal());
 > $_APPLICATION->end_section();

This isn't quite as transparent as $_SESSION is and $_APPLICATION would 
also not be a superglobal. What I would like to see at the end of this 
is a $_APPLICATION variable (or $_APP? some poeple complained that 
$_APPLICATION is too long) that behaves *exactly* like $_SESSION (in 
assignment etc)  except that its values are available not across 
sessions but across applications and instances of applications.

- Davey

Andrey Hristov wrote:

>  Hi Davey,
> I don't know whether this will be implemented in an extension but
> there are sollutions in userland : to use sysvshm+sysvsem or shmop. 
> The sysvshm+sysvsem extension exposes the C api. I know for 2 wrappers

> around this API to make the use of shared memory (and thus something 
> like application wide variables) easy to implement in userspace:
> 1)
>
http://www.php-tools.de/site.php?&PHPSESSID=b4a4ab7142b7d3209c7eee976912
0cba
> &file=patMisc/shmc.xml
> 2)http://www.hristov.com/andrey/projects/php_stuff/shm.php.gz
> 
> The second one is written according to PEAR CS. It exposes 4 classes.
> Shm_Protected_Var is what is needed to implement $_APPLICATION:
> 
> // masv = my application shared vars. This is the name of the shared
> var. // Only the first 4 chars are used to calculate memory address. 
> $_APPLICATION = new Shm_Protected_Var("masv", 1024 /*memory*/);
> $_APPLICATION->start_section() var_dump($_APPLICATION->getVal());
> $_APPLICATION->end_section();
> 
> Regards,
> Andrey
> 
> 
> ----- Original Message -----
> From: "Davey" <davey@php.net>
> To: <internals@lists.php.net>
> Sent: Thursday, August 07, 2003 3:36 PM
> Subject: [PHP-DEV] [Proposal] Idea for Application level variables
> 
> 
> 
> > […]

> > […]

---

## #3815 — Davey — 2003-08-07T20:39:16+00:00

URL: https://externals.io/message/3805#3815 · In reply to: #3805

The storage, just like $_SESSION can be any of the pre-defined settings 
(mm, files or SQLite (php5)) or "user" and can then be stored in a 
database or whatever system the user wants. (This would indeed mean that 
  an application_set_save_handler() will also need to be there)

I think that the $_APPLICATION variables should have exactly the same 
life expectancy and garbage collection as $_SESSION variables currently 
do, though they should be set independantly. Just as with $_SESSION you 
can have more control by using your own "user" method to store the data.

- Davey

Jeremy S. Johnstone wrote:

> I noticed something which you said, and forgive me if this part may be
> obvious, but you mentioned across instances of applications? Do you mean
> something like a shared memory between all web connections to the
> server? One issue I could forsee if this is the case, what happens when
> there is no connections to the server for an extended period of time
> (extended being even as short as a few minutes)? Should PHP store this
> superglobal's value indefinitely, or perform some type of garbage
> collection? If PHP should clean up after itself, what criteria would you
> expect to be followed for deciding if something is no longer useful? I
> don't think you would want this criteria configurable in a ini setting
> for example, because hosting companies all do something different. If a
> developer were to use this feature, they would need a standardized
> timeframe that the values would last. This is just a couple things I
> think would need to be considered before implementing something like
> this. If I am way out in left field, I apologize.
> 
> -Jeremy
