Results 1 to 4 of 4

Thread: $_server

  1. #1
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    163
    Thanks
    57
    Thanked 0 Times in 0 Posts

    Default $_server

    Partial output of

    Code:
    echo '<br />
    <br />
    <br />
    $_SERVER
    <br />
    <br />
    <br />';
    foreach ($_SERVER as $bigkey => $bigvalue) {
    echo "The value of $_SERVER $bigkey is $bigvalue <br />";
    }
    at http://www.njexpungements.com/test.php:

    The value of Array REQUEST_URI is /test.php
    The value of Array SCRIPT_NAME is /test.php
    The value of Array PHP_SELF is /test.php

    Presumably the three indicated elements are not interchangeable, but I can't see the difference.

    Thoughts?

    A.

  2. #2
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    2,469
    Thanks
    16
    Thanked 422 Times in 420 Posts
    Blog Entries
    20

    Default

    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  3. The Following User Says Thank You to Beverleyh For This Useful Post:

    marain (04-02-2013)

  4. #3
    Join Date
    Apr 2012
    Location
    Central New Jersey
    Posts
    163
    Thanks
    57
    Thanked 0 Times in 0 Posts

    Default

    Awesome!

    A.

  5. #4
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Mod's note: the forum software automatically makes words lowercase in order to prevent "screaming" titles. In this case it's changing $_SERVER to $_server, which would not be functional. It probably won't matter for anyone, but just in case someone comes across this thread, you must use $_SERVER.



    Here's the official documentation:
    http://php.net/manual/en/reserved.variables.server.php


    The value of Array REQUEST_URI is /test.php
    The value of Array SCRIPT_NAME is /test.php
    The value of Array PHP_SELF is /test.php

    Presumably the three indicated elements are not interchangeable, but I can't see the difference.
    I can't remember the exact differences, but they can vary. They'll usually be the same, but if you are using mod_rewrite for 'pretty URLs' you'll get some variation here (the requested filename, and the actual file on the server), and I believe the other two might vary based on how you use include(), although I'm not certain about that.


    For the record, you can test all of this another way:
    PHP Code:
    print_r($_SERVER); 
    Note that $_SERVER can vary slightly on different servers (and depending on your configuration or maybe even how a page loads), so it's worth checking your configuration as well as the manual.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Similar Threads

  1. action=\"$_SERVER[PHP_SELF]\">
    By expmsr in forum PHP
    Replies: 2
    Last Post: 08-12-2010, 03:21 PM
  2. $_server containing directory?
    By bluewalrus in forum PHP
    Replies: 0
    Last Post: 10-21-2009, 04:45 PM
  3. $_SERVER['REMOTE_ADDR'], << need help with!
    By hmsnacker123 in forum PHP
    Replies: 1
    Last Post: 07-04-2008, 10:06 PM
  4. $_SERVER['QUERY_STRING']-php
    By manashi_130582 in forum PHP
    Replies: 3
    Last Post: 04-18-2006, 09:51 AM

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
  •