SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Coding without Global vars

    Question. Are there any good tutorials for programming a website without using registered globals? The problem is I have been using global vars to create websites but seeing it is a security issue I would like to look at rethinking my coding structure.

    I normally create a template design and have the middle part be dynamic where it reads the global variable and includes the file accordingly. Meaning in the page I have my outside design and the data part, the middle of the page mainly, I have

    PHP Code:
    include $this
    Where $this is determined by a switch. The switch reads off the global variable. So say the url is www.site.com?var=main

    So then the switch looks at var and if var equals main then $this would be main.php. Then it would include that file. Is that a "weak" way of doing it? Can anyone point me to tutorials on better ways of doing this? I do it this way to make updating links and what not easier. But the more complex it gets the sloppier the code gets and using the global variable seems to be the wrong way of doing it. Any help would be appreciated.

    Thanks
    The Chaos

  2. #2
    SitePoint Wizard samsm's Avatar
    Join Date
    Nov 2001
    Location
    Atlanta, GA, USA
    Posts
    5,011
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's an article: http://www.webmasterbase.com/article/758

    See if that helps
    Using your unpaid time to add free content to SitePoint Pty Ltd's portfolio?

  3. #3
    SitePoint Wizard Sillysoft's Avatar
    Join Date
    May 2002
    Location
    United States :)
    Posts
    1,691
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks! Yeah I do use that, not the _$VAR stuff but the full $HTTP_GET_VARS line. I didnt know _$VAR was accessible from inside a function though! That helps out a lot.


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
  •