View Full Version : Global Buffers On Server

09-22-2009, 11:06 AM
I'm developing an e-commerce site involved with a lot of database access and naturally I want to keep the DB access to a minimum. Keeping some information in a server buffer definitely helps. I do have about 10 PHP script files for the entire site. Do you know if variables declared outside of functions in PHP modules are considered global variables and accessible from any executing PHP scripts unauthorized changes are protected against ?


09-22-2009, 02:20 PM
Variables are not available from the global scope in functions and methods (with the exception of some resources) by default. Variables can be globalized in any function or method to work on a reference of the variable by either calling the global keyword or by accessing the $GLOBALS superglobal.
So to answer you're question, no you're variables are not safe. If you need read-only variables, consider the use of constants instead. If you require greater scope control, consider using an OO approach to you're code instead - at least objects can be typehinted to control forced access.