So I am building a web service that generates charts from a large amount of data. The problem I am running into is that to generate one chart, there can be up to 5 requests set. The variable preservation was just getting ridiculous.
So, question is - what is the best solution. I would like to have some sort of global variables, but register globals is turned off (I don't think that actually stops me from using the global keyword, just the globals array - please correct me if I am wrong)
My solution so far has been to create two files.
I have included preserve variables in every script that needs it, and it seems to be working well.
So, is there a better way?
So, question is - what is the best solution. I would like to have some sort of global variables, but register globals is turned off (I don't think that actually stops me from using the global keyword, just the globals array - please correct me if I am wrong)
My solution so far has been to create two files.
Code:
One is called set_globals, which declares an array and initializes all the key/value pairs to defaults. THe second is called preserve variables, which simple checks if any request variables were sent and sets them in the array if they were not. At the top of the preserve variables file, I just require_once the set_globals.
So, is there a better way?
Comment