Make global array in php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
woren
Forum Newbie
Posts: 4
Joined: Wed Jul 21, 2004 5:37 am

Make global array in php

Post by woren »

Hello to all
I'm looking for way to make global array in php+(apache) under windows ,
I need to send data between users (for make counter) on server side for example.
Now I using file or database but it isn't nice or good way.
Hope you have any other way.
And wetting for yours suggestion.

Thanks
Oren wisman
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

If this state need to be saved, you can't really do it other ways.. There's shared memory operations and things, search php.net's documentation for those..
woren
Forum Newbie
Posts: 4
Joined: Wed Jul 21, 2004 5:37 am

Post by woren »

feyd wrote:If this state need to be saved, you can't really do it other ways.. There's shared memory operations and things, search php.net's documentation for those..
but shared memory is only for linux !!
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's actually possible to do it with windows.. although you won't be able to use native php for it..
woren
Forum Newbie
Posts: 4
Joined: Wed Jul 21, 2004 5:37 am

Post by woren »

feyd wrote:it's actually possible to do it with windows.. although you won't be able to use native php for it..
ok how ??
can you upload an example to the forum ??


thanks
OREN
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

there are 2 ways that I know of, using the w32api, which stinks. Or writing your own extension.

I'd use the database though, which you're against for some reason..
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

why not do

Code: Select all

<?

$_SESSION["var"] = array("1","2","3");

?>
then to access the array

Code: Select all

<?

echo $_SESSION["var"][0];
//outputs 1 on any page

?>
User avatar
evilmonkey
Forum Regular
Posts: 823
Joined: Sun Oct 06, 2002 1:24 pm
Location: Toronto, Canada

Post by evilmonkey »

How about the array through the adress bar? Append it to your links...not sure if it works for arrays, but I don't see why it shouldn't.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

sessions and get params doesn't help sending data to other users on the site all that well..
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

Post by JAM »

feyd wrote:I'd use the database though, which you're against for some reason..
I'm also abit startled by this. Database 'seems' to be the way to go and likely abit easier than any alternative approach.

I find the topic overall interesting, so I'd also like to know how come this solution isn't working as wanted.
Post Reply