如何生成变量html页面,创建动态Web网页需要知道的10个服务器变量(翻译)

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

Every time you request a Web page, an immense amount of activity takes place behind the scenes: your request is sent to a DNS server, an IP address is found, the corresponding Web server is contacted, and the resulting data stream is decoded and rendered by your Web browser as an HTML page. In addition to the actual HTML content requested, however, the Web server also includes a number of important "server variables" in its response. These variables contain information about both the Web server environment - its name, IP address and software - and the current script execution environment - the script name and path and the query string.

These variables are often used by clever Web developers to make their scripts more dynamic and robust. This document outlines (Table A) some of the more useful server variables that a Web server typically sends out when it responds to an HTTP request, and also explains when and how you could use each one on your Web site.

Note:Some of these variables may not be available in all Web servers.

For more information on these and other server variables, consider taking a look at the CGI 1.1 specification.

Table A

Variable

What It Contains

What It's Useful For

HTTP_USER_AGENT

An identification string sent by the client making the request. For example: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8) Gecko/20051111 Firefox/1.5.

Client detection and logging; creating code that works differently in different browsers.

HTTP_ACCEPT_ENCODING

The list of encodings the client is able to decode.

Improving transfer speeds by using GZIP encoding (for example) to compress page data.

REMOTE_ADDR

The IP address of the client making the request.

Obtaining the user's geographical location for targeted advertising or localized information retrieval; restricting access to specific IP addresses or groups of IP addresses.

DOCUMENT_ROOT

The server's document root directory (as defined in its configuration).

Constructing relative/absolute paths when uploading, copying or moving files through a Web application.

SERVER_SOFTWARE

The server's signature, indicating the name and version of the server as well as any software running on it. For example: Apache/2.0.55 (Win32).

Identifying server capabilities.

QUERY_STRING

The list of variable-value pairs that follow the "?" in the requested URL.

Retrieving and parsing the variable-value pairs sent to the server via its URL.

REQUEST_METHOD

The method used to make the URL request. For example GET, POST or PUT.

Identifying the method used to request the page, and thereby accessing the appropriate namespace for variable retrieval.

SCRIPT_NAME

The server path to the requested resource (relative to the document root).

Retrieving the name and path to the currently-executing script or resource.

HTTP_ACCEPT_CHARSET

The character sets the client is able to receive.

Sending page data in a preferred character set.

REMOTE_USER

When using HTTP authentication, the username supplied for authentication.

Content personalization; credential verification.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值