Page 1 of 1

How do I create a shared variable in PHP?

Posted: Mon Jul 14, 2003 5:14 am
by hanct
I read some tutorials on variable in PHP, but none seem to talk about shared variable, variable that is shared among all clients....which is similar to the static variable found in JSP, where this variable is shared by all user.

No i dont want to use database, just wanna some way to create variable to hold some data to be shared by all users.

For example, I have a variable in php script:

$car=5;
$car++;
print($car);

If a user access this script, he will see the no.6 printed out. The next user access this script will see no. 7 and so on!!!!

Posted: Mon Jul 14, 2003 5:55 am
by redhair
Use fwrite (if the your server allows it)

Ok! thanks!! But if i wanted to use just variable, not using

Posted: Mon Jul 14, 2003 6:14 am
by hanct
not using file, is it possible in PHP?

Posted: Mon Jul 14, 2003 6:21 am
by redhair
I wouldnt know how to retreive a variable from something else then a database or a file (..if its supposed to be passed on to other users).
Maybe someone else knowes?

Posted: Mon Jul 14, 2003 6:48 am
by ik
Sure, you ought to keep the value of your variable anywhere between succesive calls of you script. File seems to be the best and simplest solution.

Posted: Mon Jul 14, 2003 7:40 am
by twigletmac
PHP does not offer application variables that are accessible to all users without using database or text file storage.

Mac