实例:
1,http://localhost/aaa/ (打开aaa中的index.php)
结果:
$_SERVER['QUERY_STRING'] = "";
$_SERVER['REQUEST_URI']
=
"/aaa/";
$_SERVER['SCRIPT_NAME'] =
"/aaa/index.php";
$_SERVER['PHP_SELF'] =
"/aaa/index.php";
2,http://localhost/aaa/?p=222 (附带查询)
结果:
$_SERVER['QUERY_STRING'] = "p=222";
$_SERVER['REQUEST_URI'] =
"/aaa/?p=222";
$_SERVER['SCRIPT_NAME'] =
"/aaa/index.php";
$_SERVER['PHP_SELF'] =
"/aaa/index.php";
3,http://localhost/aaa/index.php?p=222&q=333
结果:
$_SERVER['QUERY_STRING'] = "p=222&q=333";
$_SERVER['REQUEST_URI'] =
"/aaa/index.php?p=222&q=333";
$_SERVER['SCRIPT_NAME'] =
"/aaa/index.php";
$_SERVER['PHP_SELF'] =
"/aaa/index.php";
由实例可知:
$_SERVER["QUERY_STRING"] 获取查询
语句,实例中可知,获取的是?后面的值
$_SERVER["REQUEST_URI"] 获取
http://localhost 后面的值,包括/
$_SERVER["SCRIPT_NAME"] 获取当前脚本的路径,如:index.php
$_SERVER["PHP_SELF"] 当前正在执行脚本的文件名
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。