So a theory question for all you PHP Guru's out there

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crabpot8
    New Member
    • Aug 2007
    • 40

    So a theory question for all you PHP Guru's out there

    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.
    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.
    I have included preserve variables in every script that needs it, and it seems to be working well.


    So, is there a better way?
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    I'm not too sure about the problem here, but could SESSIONs help?

    Comment

    • dlite922
      Recognized Expert Top Contributor
      • Dec 2007
      • 1586

      #3
      Originally posted by markusn00b
      I'm not too sure about the problem here, but could SESSIONs help?
      uh....Yah!

      Why wouldn't session work?

      If the data needs to be secure, save session in database.

      Comment

      • Atli
        Recognized Expert Expert
        • Nov 2006
        • 5062

        #4
        Originally posted by crabpot8
        ... 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)...
        Actually, the register_global s directive only disables / enables the automatic creation of global variables for all REQUEST variables.

        It has no effect on either the global keyword or the $GLOBALS array.

        Comment

        Working...