Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Global Buffers On Server
09-22-2009, 11:06 AM #1
- Join Date
- Sep 2009
- Thanked 0 Times in 0 Posts
Global Buffers On Server
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 #2
- Join Date
- Sep 2002
- Saskatoon, Saskatchewan
- Thanked 2,662 Times in 2,631 Posts
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.
Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)PHP Code:
header('HTTP/1.1 420 Enhance Your Calm');