Re: Using The Same Page To Display A Hundred Pictures One Picture At A Time
Jim Carlock wrote:
> <xclarky@xxxxxxxxx> posted:
> > Have you considered using sessions? You could use them to create
> > a temporary cache of the array quite easily.
>
> <?php
> session_start();
> if (!isset($_SESSION['array_cache'])) {
> $array = array('value', 'value');
> $_SESSION['array_cache'] = $array;
> } else {
> $array = $_SESSION['array_cache'];
> }
> ?>
>
> Thanks, Clark(?). I'll give that a go.
>
> Jim Carlock
> Post replies to the newsgroup.
I admit I don't know the internal workings of PHP too well, but I'm
really not sure storing the array as a session variable will actually
help anything.
As far as I can tell session variables are just little text files
stored server-side per connection. As such there are two points:
1) you're just loading the array from a text file, so it makes no
difference whether you're loading it from the text file or creating it
in the script
2) it may actually be serialised to be put in said text file, and as
such you're actually incurring extra time serialising and unserialising
it every page refresh.
Plus even if this way does manage to save some server processing (in a
way I can't see) then it'll only work on subsequent page loads of each
session. As such the array still has to be created once per
user/session of the web site. If the array isn't going to change it
might be best to create the array and serialise it to a text file
that's open for everyone. That way the script can just load it from
there even for the first load per session. And if it only changes every
now and again (i.e. with an update from you rather than in the script
over a session) then you can make a separate script that will load it
in, make the changes, and then save it again.
But I could be way off with the way sessions work.
.
Relevant Pages
- RE: Session variables and reference
... Session variable that is an array of a class I created: ... public cut//copy constructor ... Kmax = myCut.Kmax; ... I realized that when I set my temporary array to equal the session array, ... (microsoft.public.dotnet.framework.aspnet) - Re: help with array within another array
... you could make a hash with reference to hash values: ... it seems like you might want to consider using the node identifier as the first key in %SESSION, and make the value a reference to hash keyed by the owner and severity: ... I am trying to declare two associative array ... (perl.beginners) - Re: [PHP] SESSION problem
... But, if you came from a background that predated associate arrays, then using numeric indexes would seem more natural. ... looked into the session extension in that level of detail, but I doubt such a limitation would exist if there was not a very good reason for it. ... Given that I can't see into the future, even if I currently only have one set of data to store in the session I wouldn't just chuck the bits of paper from the file into the filing cabinet. ... The root level of the session array should contain descriptive keys, and I've never been in a situation where 5318008 is descriptive and gives context to the data unless you turn it upside down! ... (php.general) - Re: 2 dimension arrays
... > How do I declare an array as a session variable? ... as you have a *reference* to this array, there is really only one array ... >> Andrew wrote: ... (microsoft.public.dotnet.framework.aspnet) - Re: is xml better than a php array include file?
... When a person comes to your site you should build a session and then create ... Array 1: countries Array 2. ... > that they have to load every time a page is opened. ... > access the data in the XML file in the same way that you could access ... (alt.php) |
|