SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2011
    Location
    Florida
    Posts
    58
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Lightbulb PHP re using / refrencing variables

    Using PHP, I would like to set variables and re use them in multiple locations, kind of like settings for an app. I was trying to stay away from both session and global variables and was wondering what kind of ideas you guys had to accomplish this.

    IE: I would like to set a variable once whether its $var = 1; or $var = new Class(); and refrence $var throughout the whole app with out declaring it as a new class or setting the variable again, including inside of functions or classes.

    Any and all input would be appreciated, Thank you

  2. #2
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,194
    Mentioned
    17 Post(s)
    Tagged
    4 Thread(s)
    I would recommend looking into dependency injection.
    The only code I hate more than my own is everyone else's.


Tags for this Thread

Bookmarks

Posting Permissions

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