详解$_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"] 当前正在执行脚本的文件名
标题名称:详解$_SERVER函数中QUERY_STRING和REQUEST_URI区别
当前网址:http://myzitong.com/article/jpiegj.html