Page 211 - Open Soource Technologies 304.indd
P. 211

Unit 9: Web Techniques



            $HTTP_ENV_VARS                                                                        Notes
                 Contains the values of any environment variables, where the keys of the array are the
                 names of the environment variables.
            Because names like $HTTP_GET_VARS are long and awkward to use, PHP provides shorter
            aliases: $_COOKIE, $_GET, $_POST, $_FILES, $_SERVER,and $_ENV. These variables are not
            only global, but also visible from within function definitions, unlike their longer counterparts.
            These short variables are the recommended way to access EGPCS values. The $_REQUEST array
            is also created by PHP if the register_globals option is on; however, there is no corresponding
            $HTTP_REQUEST_VARS array. The $_REQUEST array contains the elements of the $_GET,
            $_POST, and $_COOKIE arrays.
            PHP also creates a variable called $PHP_SELF, which holds the name of the current script, relative
            to the document root (e.g., /store/cart.php). This value is also accessible as $_SERVER[‘PHP_SELF’].
            This variable is useful when creating self-referencing scripts.

            Self Assessment

            Multiple choice questions:

               1.  A simple request for a document or resource residing at a specific URI is called
                 (a)  SET                        (b)  POST
                 (c)  GET                        (d)  None of these
               2.  A request that  is only looking for HTTP header information on the resource, not the
                 resource itself is called
                 (a)  SET                        (b)  POST
                 (c)  HEAD                       (d)  None of these
            True or False:
               3.  PHP can provide dynamic content according to browser type.
                 (a)  True                       (b)  False
               4.  PHP creates a separate global variable for every form parameter, every piece of request
                 information, and every server configuration value.
                 (a)  True                       (b)  False

            9.3 Server Information

            The $_SERVER array contains a lot of useful information from the web server. Much of this
            information comes from the environment variables required in the CGI specification.
            Here is a complete list of the entries in $_SERVER that come from CGI:

            SERVER_SOFTWARE
                 A string that identifies the server (e.g., “Apache/1.3.22 (Unix) mod_perl/1.26 PHP/4.1.0”).
            SERVER_NAME

                 The hostname, DNS alias, or IP address for self-referencing URLs (e.g., “www.example.
                 com”).

              GATEWAY_INTERFACE
                 The version of the CGI standard being followed (e.g., “CGI/1.1”).


                                             LOVELY PROFESSIONAL UNIVERSITY                                   205
   206   207   208   209   210   211   212   213   214   215   216