Page 1 of 1

Make global array in php

Posted: Wed Jul 21, 2004 5:37 am
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

Posted: Wed Jul 21, 2004 5:40 am
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..

Posted: Wed Jul 21, 2004 5:45 am
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 !!

Posted: Wed Jul 21, 2004 5:45 am
by feyd
it's actually possible to do it with windows.. although you won't be able to use native php for it..

Posted: Wed Jul 21, 2004 5:51 am
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

Posted: Wed Jul 21, 2004 5:56 am
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..

Posted: Wed Jul 21, 2004 10:34 am
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

?>

Posted: Wed Jul 21, 2004 10:55 am
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.

Posted: Wed Jul 21, 2004 12:18 pm
by feyd
sessions and get params doesn't help sending data to other users on the site all that well..

Posted: Wed Jul 21, 2004 6:12 pm
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.