SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Oct 2003
    Location
    Malaysia
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $PHP_SELF and $_SERVER['PHP_SELF']

    What is the difference between $PHP_SELF and $_SERVER['PHP_SELF']?

    Why do people use $_SERVER['PHP_SELF'] if it is longer and more difficult to type?

  2. #2
    SitePoint Guru
    Join Date
    Nov 2004
    Location
    Parry Sound, ON
    Posts
    725
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just in case your code ever has to run where register_globals is off.

  3. #3
    Romans 12:2 codyrockx's Avatar
    Join Date
    Jul 2003
    Location
    Newberg, Oregon
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    using it through the $_SERVER array is always better, despite it `taking more time` because of more typing; it'll save you many hassles. Among knowing exactly where it came from, you will then avoid any server change issues that may result in your program falling apart.
    Codyrobert.com - Designer and Developer

  4. #4
    SitePoint Enthusiast mullen's Avatar
    Join Date
    Jul 2004
    Location
    Durham, UK
    Posts
    82
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Think about what would happen if someone added "...?PHP_SELF=blah" to the end of the URL. Without accessing PHP_SELF through the superglobal $_SERVER array, you are introducing easily avoidable security vulnerabilities.

  5. #5
    $this->toCD-R(LP); vinyl-junkie's Avatar
    Join Date
    Dec 2003
    Location
    Federal Way, Washington (USA)
    Posts
    1,524
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Always have register globals off, and then you don't have to worry what a visitor might put at the end of a URL.

    I've seen some pretty strange URL endings in my server log lately. They've all up on my 404 page.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more
    Showcase your music collection on the Web


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
  •