Superglobals

So far (end of chapter 1, just before jumping into the OO part) the book doesn't say a word about superglobals. I think this is an important topic and I suppose there must be questions about the superglobals on the exam.

The best place to get an idea about the superglobals is this PHP.net manual entry.
Note how there was a different set of superglobals prior to php.4.1 but I was lead to believe that the exam is concentrated on stuff after 4.1. (and before php5).

Briefly, here's the list of superglobals:

  • $_GET - variables sent using a GET HTTP request
  • $_POST - variables sent using a POST HTTP request
  • $_COOKIE - array of all cookies that are sent by the server
  • $_REQUEST - a merge of the three above
  • $_SESSION - array containing the session data
  • $_SERVER - server variables like REMOTE_ADDR, SCRIPT_NAME, REQUEST_URI, etc.
  • $_ENV - more or less the same as $_SERVER
  • $_FILE - data about uploaded files
  • $GLOBALS - array of all global variables, see the previous blog entry for an example

Bookmark and Share

Somewhat related posts

3 Responses to “Superglobals”

  1. Yami King Says:

    Quite a late comment, but important to know:
    $_FILE should be $_FILES

    :)

  2. Stoyan Says:

    True! :) This always gets me. In any decent editor with source highlighting, I can type until the keyword is highlighted, then I know I'm right. Unforunatelly there was a similar question in the actual exam, I'm not sure I got it right. I mean c'mon, global $var, $_GLOBALS['var'], argh… :D

Leave a Reply