Re: Are application wide variables possible with PHP4?

From: Date: Thu, 02 Mar 2000 23:45:06 +0000
Subject: Re: Are application wide variables possible with PHP4?
Groups: php.version4 
Request: Send a blank email to php-version4+get-11412@lists.php.net to get a copy of this message
Hi Peter, Andreas, Damien & Scott! Thank you for your help to find a good way to use application wide variables with PHP! So, I want to list the solutions you gave here: 1. Saving variables to shared memory by use of the modules sysvshm and sysvsem. I looked into the documentation of these modules. There were listed some limitations. Is this working for all operating systems or is this working only for some Unix platforms? The headers in the C - sources of these modules contain a warning that this has only been tested for Solaris 2.6. Does someone know more about chances and limitations of these modules for implementing application wide variables with it? eg. Could there be a problem that two scripts try to write the same block of memory and a third is trying to read that garbadge??? Peter: What exactly do you mean is not good programming style? 2. Save the variables into files on disk. This seems to be a quick way, but I don´t know if it is really a good solution because the problem Andreas described that reading or writing of a file by more than one process may not be easy to work around. On the other hand, I don´t believe that this would scale good. 3. Save variables into the database. This seems to be the most secure and fast solution, if solution 1 does not work (I hope it does). Here is not the problem that more then one process manipulates a field at a time, cause access control is provided by database. Marc. ------------- Peter Kovacs wrote: > You can also use environmental variables for this type of thing. > However, > I would imagine that you'd want to be able to change the variable. > (Although that's probably bad programming practice) In which case I'd > say > that shared memory is probably your best bet. Andreas Karajannis wrote: > Damien Mc Kenna wrote: > > > > How about just using include files? It may be a bit more work for > the > > server to have to keep reading-writing out files, but it'd probably > work > > just as well. > > Probably not. Imagine one server process (or more) process(es) trying > to > update variables with other processes simultaneously reading the file? > > -Andreas > Scott Wheeler wrote: > Marc, > > I ran into the same trubs. I was at the point of passing cookies to > the > user to store stuff. Not a good idea since my boss forbids cookies. > I used > Sessions in PHPLib and it was ok. I've been running PHP4 with > sessions and > I had to register the variable on every script. Since the last two > releases > I don't seem to have to. The way sessions work is by using a temp > directory > that stores the users variables into a file and the other way is to > create > session tables in your db. I use the flat file method seems to be > fast and > efficient for me. > > hope it helps... > l8r > > scott Damien Mc Kenna wrote: > At 06:40 AM 3/2/00, you wrote: > > Use the functions provided by the sysvshm and sysvsem modules for > this. > > Look in the manual for further information. > > How about just using include files? It may be a bit more work for the > > server to have to keep reading-writing out files, but it'd probably > work > just as well. > Just my 2 credits. Andreas Karajannis wrote: > Use the functions provided by the sysvshm and sysvsem modules for > this. > Look in the manual for further information. > > -Andreas Marc Aßmann started to write: > Hello, > > My question came up with the current running thread 'Sessions with > Shared > memory(mm) broken?'. > Andreas Karajannis and Luis Gallego write that they are trying to use > "shared > memory" to save > session variables. What does that mean? > > I would like to have a possibility in saving variables that persist > through > the whole runtime of the server, > like it can be done in ColdFusion. > > Everyone I asked before just said "no, it´s not possible, you have to > save > them in files or in a database > and initialize them everytime a script is called". > > Does anyone know better? > > Marc.

« previous php.version4 (#11412) next »