Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    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 ?


  • #2
    God Emperor Fou-Lu's Avatar
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 
    Been gone for a few months, and haven't programmed in that long of a time. Meh, I'll wing it ;)


    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts