CGI中常用的环境变量
简单总结一下CGI中常用的环境变量,
当然我本初学,有一些也没用过,有一些仅是网上资料的汇总.
另外只是概要性的叙述,有一些变量在某些时候会返回空值,具体情况并未一一列出.
CGI中常用的环境变量
1. CONTENT_LENGTH
2. DOCUMENT_ROOT
3. HTTP_REFERER
4. HTTP_USER_AGENT
5. PATH_INFO
6. PATH_TRANSLATED
7. QUERY_STRING
8. REMOTE_ADDR
9. REMOTE_HOST
10. REQUEST_METHOD
11. SCRIPT_NAME
12. REQUEST_URI
13. SERVER_NAME
14. SERVER_PORT
概要1. 获取POST方法中传递实际信息的有效字节数
(CONTENT_LENGTH)
概要2. www目录信息获取
(DOCUMENT_ROOT)
概要3. 链接到当前页面的前一页面的 URL 地址。不是所有的用户代理(浏览器)都会设置这个变量,而
且有的还可以手工修改它。
因此,这个变量不总是真实正确的。
(HTTP_REFERER)
概要4. 客户端的名称和版本号
(HTTP_USER_AGENT)
概要5. http://www.test.com/index.php/foo/bar.html?c=index&m=search
我们可以得到 $_SERVER['PATH_INFO'] = ‘/foo/bar.html’,而此时 $_SERVER['QUERY_STRING'] =
'c=index&m=search';
(PATH_INFO)
概要6. 获取本文件的绝对路径
(PATH_TRANSLATED)
概要7. 获取IP地址
(REMOTE_ADDR)
概要8. 获取hostname
(REMOTE_HOST)
概要9. 获取请求方法,一般为GET,POST,HEAD
(REQUEST_METHOD)
概要10. # http://www.yoursite.com/example/ -- -- -- /
# http://www.yoursite.com/example/index.php -- -- -- /example/index.php
# http://www.yoursite.com/example/index.php?a=test -- -- -- /example/index.php?a=test
# http://www.yoursite.com/example/index.php/dir/test -- -- -- /example/index.php/dir/test
(REQUEST_URI)
概要11. # http://www.yoursite.com/example/ -- -- -- /example/index.php
# http://www.yoursite.com/example/index.php -- -- -- /example/index.php
# http://www.yoursite.com/example/index.php?a=test -- -- -- /example/index.php
# http://www.yoursite.com/example/index.php/dir/test -- -- -- /example/index.php
(SCRIPT_NAME)
概要12. 服务器的hostname或IP
(SERVER_NAME)
概要13. 服务器的监听端口
(SERVER_PORT)
概要14. http://www.test.com/index.php/foo/bar.html?c=index&m=search
我们可以得到 $_SERVER['PATH_INFO'] = ‘/foo/bar.html’,而此时 $_SERVER['QUERY_STRING'] =
'c=index&m=search';
注意:QUERY_STRING只是用于GET方法.
(QUERY_STRING)
Wed, 24 Aug 2022 21:45:34 -1100
With just a few clicks from the comfort of your home, you can quickly and easily purchase train tickets on Paytm. You no longer need to wait in lengthy lines to purchase an IRCTC ticket since Paytm makes it simple, quick, and safe to book a train ticket online. With us, you may make reservations for any type of train, class, or destination. paytm Look for information about Paytm like as the train's PNR status, departure and arrival times between two specific locations, and more. We strive to provide simple services that will provide you a trouble-free train ticketing experience.
Thu, 18 Jan 2024 20:16:16 -1100
JNANABHUMI AP provides all latest educational updates and many more. The main concept or our aim behind this website has been the will to provide resources full information on each topic which can be accessed through Internet. To ensure that every readers get’s what important and worthy about the topic they search and link to hear from us. jnanabhumiap.in Jnanabhumi AP is a startup by passionate webmasters and bloggers who have passion to provide engaging content which is accurate, interesting and worthy to read. We are mope like a web community where you can find different information’s, resources, topics on day to day incidents or news. We provide you the finest of web content on each and every topics possible with help of editorial and content team.