PHP Superglobals

PHP supports the concept of superglobals (sometimes referred to as automatic globals or autoglobals). Superglobals are variables that are available in any scope.

All superglobals are described in detail on the php.net website. The PHP support in CICS® TS Feature Pack for Dynamic Scripting V2.0 enables a subset of these superglobals for use by PHP script developers.

Superglobals that are supported by CICS TS Feature Pack for Dynamic Scripting V2.0 are as follows:

$_SERVER

The $_SERVER superglobal gives access to the CICS TS Feature Pack for Dynamic Scripting V2.0 attributes and certain HTTP request attributes. The complete list of keys that are supported is shown in Table 1
Table 1. $_SERVER supported keys
Key Value

$_SERVER['argv']

This variable returns the query string that is associated with a request.

$_SERVER['DOCUMENT_ROOT']

The path to the application root.

$_SERVER['HTTP_ACCEPT']

The value of the Accept header.

$_SERVER['HTTP_ACCEPT_CHARSET']

The value of the Accept-Charset header.

$_SERVER['HTTP_ACCEPT_ENCODING']

The value of the Accept-Encoding header.

$_SERVER['HTTP_ACCEPT_LANGUAGE']

The value of the Accept-Language header.

$_SERVER[HTTP_CONNECTION']

The value of the Connection header.

$_SERVER['HTTP_HOST']

The value of the Host header.

$_SERVER['HTTP_REFERER']

The value of the Referer header.

$_SERVER['HTTP_USER_AGENT']

The value of the User-Agent header.

$_SERVER['HTTPS']

The value 'https' if the request was made by using the https transport.

$_SERVER['REMOTE_ADDR']

The IP address of the client that is making the request.

$_SERVER['REMOTE_HOST']

The host name of the client that is making the request.

$_SERVER['REMOTE_PORT]

The port number of the client that is making the request.

$_SERVER['SCRIPT_FILENAME']

The file name of the script that is being invoked.

$_SERVER['SCRIPT_NAME']

The name of the script that is being invoked.

$_SERVER['SERVER_PORT']

The port number that the server accepted the request on.

$_SERVER['REQUEST_METHOD']

The HTTP method of the request.

$_SERVER['REQUEST_URI']

The URI associated with the HTTP request.

$_SERVER['REQUEST_TIME']

The time stamp when the request was dispatched to the script.

$_GET

The $_GET variable is used to access URL query parameters that are associated with an HTTP request. URL query parameters are most commonly used for HTTP GET requests, but they are supported for all HTTP request types. For the following request:/search?title=Rose&author=Eco
  • $_GET['title'] has the value "Rose"
  • $_GET['author'] has the value "Eco"

$_POST

The $_POST variable is similar to the $_GET variable except that it processes the body of the HTTP POST request if the content type of the body is application/x-www-form-urlencoded.

$_COOKIE

The $_COOKIE variable allows the script developer to query the cookies that were sent by the client for the request. If the cookie key uses the '[]' notation to denote an array accessor, the cookie values can be accessed through PHP arrays.

$_REQUEST

The $_REQUEST variable provides the contents of the $_GET, $_POST, and $_COOKIE arrays. If a parameter with the same name appears in two (or more) of the individual arrays, the value for that parameter in $_REQUEST is undefined.

$HTTP_RAW_POST_DATA

The $HTTP_RAW_POST_DATA variable contains the raw post data that is transmitted as part of the HTTP POST request. This variable is not available for application/x-www-form-urlencoded and multipart/form-data content types.

$_FILES

The $_FILES variable contains information about any files that were uploaded during the current HTTP request. Given the following HTML form:
<form action="http://localhost:8080/testupload.php">
<input type="file" name="myfile"/>
</form>
The $_FILES variable can be accessed by the following script:
<?php
echo $_FILES['myfile']['name'] . "\n";      // name of the file on the client
echo $_FILES['myfile']['type'] . "\n";      // content type - text/plain
echo $_FILES['myfile']['size'] . "\n";      // file length
echo $_FILES['myfile']['tmp_name'] . "\n";  // path to the temporary file on the server
echo $_FILES['myfile']['error'] . "\n";     // error code
?>
Currently, the content type of the file is not saved during the upload, so the value for $_FILES['myfile']['type'] is always text/plain.