Programming C# C++ (7) Delphi (604) Java (8) JavaScript (55) perl (40) mysql (3) perl CGI (3) php (12) VBScript (1) Visual Basic (1)
Exchange Links About this site Links to us
|
What kind of environment variables does a web context provide?
This article has not been rated yet. After reading, feel free to leave comments and rate it.
There are three classes of environment variables:
- Server specific environment variables
- Script specific environment variables
- Request specific environment variables (read from the headers)
Server specific environment variables
The first group of environment variables are server-specific and
be the same value for any request.
|
Variable Name
|
Description
|
Example
|
|
SERVER_SOFTWARE
|
The name and version of the server software answering the HTTP
request.
|
Apache/2.0
|
|
SERVER_NAME
|
The server hostname. This could also be the DNS alias or IP
address.
|
MACHINE_42
|
|
GATEWAY_INTERFACE
|
The CGI revision that this server complies with.
|
CGI/1.1
|
Script specific environment variables
The next group of environment variables are specific to the script, so
expect them to vary.
|
Variable Name
|
Description
|
Example
|
|
SERVER_PROTOCOL
|
The name and version number of the protocol that called the
script.
|
HTTP/1.0
|
|
SERVER_PORT
|
The port number for the script.
|
80
|
|
REQUEST_METHOD
|
The method for the CGI request.
|
GET (or POST, or HEAD)
|
|
PATH_INFO
|
Any extra path information that follows the script path in the
URL. If present, it is passed as an argument to the script. For
instance, http://hostname/cgi-bin/EnvVars.cgi/PathInfo
|
/PathInfo
|
|
PATH_TRANSLATED
|
A virtual-to-physical mapping of PATH_INFO, which can be used
directly as an absolute path or file.
|
hostname\cgi-bin\PathInfo
|
|
SCRIPT_NAME
|
A virtual path to the script. Useful if you output HTML code
that refers back to the script.
|
/cgi-bin/EnvVar.cgi
|
|
QUERY_STRING
|
A key variable when using METHOD=GET from your web page. It
contains the information following '?' in the URL, and passes it
to the script. For instance,
http://hostname/cgi-bin/EnvVars.cgi?QueryString
|
QueryString
|
|
REMOTE_HOST
|
The hostname making the request. If it is not available, then
the IP address should be in REMOTE_ADDR. This value isn't always
set.
|
hostname.com
|
|
REMOTE_ADDR
|
The IP address of the client making the request.
|
128.18.32.229
|
|
AUTH_TYPE
|
The protocol-specific authentication method used to validate
users. Only used if the server supports authentication.
|
(varies)
|
|
REMOTE_USER
|
If the server supports authentication, and the script is
protected, then this value will hold the username of the
individual.
|
(varies)
|
|
REMOTE_IDENT
|
This variable is used solely for logging, if the HTTP server
supports RFC 931 identification. In those cases, it will be set
to the remote user name.
|
|
|
CONTENT_TYPE
|
For requests made with METHOD=POST, this will be the content
type of the data.
|
|
|
CONTENT_LENGTH
|
The length in bytes of the content being passed (set by the
client).
|
|
Environment variables from header lines
These variables are set if there were header lines received from the
browser.
|
Variable Name
|
Description
|
Example
|
|
HTTP_ACCEPT
|
The MIME types the client will accept.
|
'image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png,
*/*'
|
|
HTTP_USER_AGENT
|
The browser that the client is using. This is useful if you want
to present browser specific pages to your users. If the user has
installed additional tools like the Yahoo companion, you'll see
that in this field as well.
|
(Internet Explorer 4.0): Mozilla/4.0 (compatible; MSIE 4.01;
Windows 2000;)
|
Comments:
|
|
|
|
Hi
I find $ENV{HTTP_REFERENCE} not working
|
|
|
|
|
It's HTTP_REFERER, not HTTP_REFERENCE
Note that HTTP_REFERER is written with a single R at the end.. not *REFERRER
|
|