【转载】详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别
实例:
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"] 当前正在执行脚本的文件名
推荐阅读
-
详解PHP中strlen和mb_strlen函数的区别
-
JavaScript中的普通函数和箭头函数的区别和用法详解
-
详解PHP中strlen和mb_strlen函数的区别_PHP教程
-
SQL SERVER中强制类型转换cast和convert的区别详解
-
javascript中函数定义以及声明和表达式区别实例详解
-
详解PHP中strlen和mb_strlen函数的区别
-
详解PHP中strlen和mb_strlen函数的区别
-
在C++中,函数名前的const和函数名后的const的区别详解
-
【转载】详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别
-
JavaScript中的普通函数和箭头函数的区别和用法详解