第一种、利用$_SERVER内置数组变量
相对较为原始的$_SERVER['QUERY_STRING']来获取,URL的参数,通常使用这个变量返回的会是类似这样的数据:name=tank&sex=1
如果需要包含文件名的话可以使用$_SERVER["REQUEST_URI"](返回类似:/index.php?name=tank&sex=1)
第二种、利用pathinfo内置函数
01
02 $test = pathinfo("http://localhost/index.php");
03 print_r($test);
04 /*
05 结果如下
06 Array
07 (
08 [dirname] => http://localhost //url的路径
09 [basename] => index.php //完整文件名
10 [extension] => php //文件名后缀
11 [filename] => index //文件名
12 )
13 */
14 ?>
第三种、利用parse_url内置函数
01
02 $test = parse_url("http://localhost/index.php?name=tank&sex=1#top");
03 print_r($test);
04 /*
05 结果如下
06 Array
07 (
08 [scheme] => http //使用什么协议
09 [host] => localhost //主机名
10 [path] => /index.php //路径
11 [query] => name=tank&sex=1 // 所传的参数
12 [fragment] => top //后面根的锚点
13 )
14 */
15 ?>
第四种、利用basename内置函数
1
2 $test = basename("http://localhost/index.php?name=tank&sex=1#top");
3 echo $test;
4 /*
5 结果如下
6 index.php?name=tank&sex=1#top
7 */
8 ?>
另外,还有就是自己通过正则匹配的处理方式来获取需要的值了。这种方式较为精确,效率暂不考虑。。。
下面拓展实践下正则处理方式:
01
02 preg_match_all("/(w+=w+)(#w+)?/i","http://localhost/index.php?name=tank&sex=1#top",$match);
03 print_r($match);
04 /*
05 结果如下
06 Array
07 (
08 [0] => Array
09 (
10 [0] => name=tank
11 [1] => sex=1#top
12 )
13 [1] => Array
14 (
15 [0] => name=tank
16 [1] => sex=1
17 )
18 [2] => Array
19 (
20 [0] =>
21 [1] => #top
22 )
23 )
24 */
25 ?>
路途漫漫...还有待继续挖掘...
荒野乱斗国际版 (BrawlStars)最新版本v56.274
下载一波超人内置修改器菜单版 安卓版v1.0.2
下载敢达决战官方正版 安卓版v6.7.9
下载敢达决战 安卓版v6.7.9
下载继承了一座戏园子无限声望铜钱版 内置菜单最新版v1.7
继承了一座戏园子折相思版是游戏的破解版本,在该版本中为玩家提
山河半世橙光清软金手指版 无限鲜花v3.24
山河半世是一款超级好玩的橙光恋爱游戏,在游戏中玩家们需要扮演
蓬莱手游折相思版 安卓版v1.0.0
蓬莱免广告版是游戏的修改版本,在该版本中为玩家去除了广告,玩
当红影后橙光游戏破解版2025 最新版v1.0
当红影后橙光破解版是一款超级好玩的娱乐圈题材的橙光游戏,在这
忽然成了万人迷清软完结版 无限鲜花版v12.15
忽然成了万人迷破解版是一款非常好玩的男性向橙光游戏,在有一天