@JonaNov 23.2004 — #[i]Originally posted by subnet_rx [/i]
[B]What's the new way to create a configuration file that every function and file has access to? Stacking it in $_SESSION? [/B][/QUOTE]
[code=php] // include configuration file // assumed in the /inc/ directory // change accordingly. // The DOCUMENT_ROOT is just the path to // your location on the server. include($_SERVER["DOCUMENT_ROOT"]."/inc/config.cfg.php"); [/code]
@subnet_rxauthorNov 23.2004 — #are functions called within that page going to have access to the variables, or do you have to include that on every PHP page?
@NogDogNov 23.2004 — #[i]Originally posted by subnet_rx [/i]
[B]are functions called within that page going to have access to the variables, or do you have to include that on every PHP page? [/B][/QUOTE] Whenever this sort of thing becomes an issue, it's always a good idea to take a step back and look at your code design. Global variables in any progamming language invariably become a maintenance nightmare. If a function needs to read a variable, make it an input parameter to that function instead. If a function needs to change a value, have it return a value instead and use it to change the value within your script.
@JonaNov 23.2004 — #[i]Originally posted by subnet_rx [/i]
[B]are functions called within that page going to have access to the variables, or do you have to include that on every PHP page? [/B][/QUOTE]
[font=trebuchet ms]Include the configuration file on every page you want access to configured variables; this way you can avoid using global variables. Moreover, you can maintain variables across multiple pages by file inclusion rather than having to use sessions (which I wouldn't recommend doing anyway). You can also use includes this way for a global set of functions accessible to every page that you want.[/font]