Home > Backend Development > PHP Tutorial > PHP的SERVER变量

PHP的SERVER变量

WBOY
Release: 2016-06-23 14:33:03
Original
907 people have browsed it

1.$_SERVER["QUERY_STRING"] 查明(query)的字符串

2.$_SERVER["PHP_SELF"]     当前正在执行脚本名

3.$_SERVER["REQUEST_URI"]访问此页面需要的URI

4.$_SERVER["SCRIPT_NAME"]包含当前脚本的路径

5.$_SERVER["HTTP_HOST"]当前请求的HOST

获取当前URL:"HTTP://".$_SERVER["HTTP_HOST"].$_SERVER["PHP_SELF"]

PS:www.test.com/do.php?ac=login

 

$_SERVER["QUERY_STRING"] = "ac=login"
$_SERVER["REQUEST_URI"] = "/do.php?ac=login"
$_SERVER["SCRIPT_NAME"] = "/do.php"
$_SERVER["PHP_SELF"]     = "/do.php"

$_SERVER["QUERY_STRING"] 获取查询语句,获取的是?后面的值
$_SERVER["REQUEST_URI"] 获取http://www.test.com后面的值,包括/
$_SERVER["SCRIPT_NAME"] 获取当前脚本的路径
$_SERVER["PHP_SELF"] 当前正在执行脚本的文件名

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template