The first, the use of $_server built-in array variables
Relatively primitive $_server[' query_string ' to get, the parameters of the URL, usually returned using this variable will be similar to the data: name=tank&sex=1
If you need to include a filename, you can use $_server["Request_uri"] (return similar:/index.php?name=tank&sex=1)
The second, the use of pathinfo built-in functions
<?php
$test = PathInfo ("http://localhost/index.php");
Print_r ($test);
04/*
05 results are as follows
-Array
07 (
=> http://localhost//url path for [dirname]
[basename] => index.php//Full file name
[extension] => PHP//filename suffix
[FileName] => index//filename
12)
13 */
?>
Third, the use of Parse_url built-in functions
<?php
$test = Parse_url ("Http://localhost/index.php?name=tank&sex=1#top");
Print_r ($test);
04/*
05 results are as follows
-Array
07 (
[Scheme] => HTTP//What protocol is used
[Host] => localhost//host name
Ten [path] =>/index.php//path
[query] => name=tank&sex=1//passed parameters
[Fragment] => Top//back root anchor Point
13)
14 */
?>
Fourth, the use of basename built-in functions
1 <?php
2 $test = basename ("Http://localhost/index.php?name=tank&sex=1#top");
3 echo $test;
4/*
5 results are as follows
6 Index.php?name=tank&sex=1#top
7 */
8?>
In addition, there is the way to get the value you need through a regular matching process. This method is more accurate, the efficiency is not considered ...
Below expand practice under the regular treatment method:
<?php
Preg_match_all ("/(\w+=\w+) (#\w+)?/I", "Http://localhost/index.php?name=tank&sex=1#top", $match);
Print_r ($match);
04/*
05 results are as follows
-Array
07 (
[0] => Array
09 (
Ten [0] => Name=tank
One [1] => Sex=1#top
12)
[1] => Array
14 (
[0] => Name=tank
[1] => sex=1
17)
KM [2] => Array
19 (
[0] =>
[1] => #top
22)
23)
24 */
?>
The journey is long ... Still need to dig ...