In the case of known URL parameters, we can use $_get to obtain the corresponding parameter information ($_get[' name ') according to our own situation; how do I get the parameter information on the URL in an unknown situation?
The first, using $_server built-in array variables
Relatively primitive $_server[' query_string ' to get, URL parameters, usually returned using this variable will be similar to the data: name=tank&sex=1
If you need to include a file name, you can use $_server["Request_uri"] (return similar to:/index.php?name=tank&sex=1)
The second, using pathinfo built-in functions
<?php$test = PathInfo ("http://localhost/index.php");p Rint_r ($test);/* The result is the following array ( [dirname] =/http Path to localhost//url [basename] = index.php //full file name [extension] + PHP //filename suffix [filename] = > index//filename) */?>
Third, the use of parse_url built-in functions
<?php$test = Parse_url ("Http://localhost/index.php?name=tank&sex=1#top");p Rint_r ($test);/* The result is the following array ( [Scheme] + HTTP//Use what protocol [host] + localhost//hostname [path] +/index.php//path [query] = Name=tan K&sex=1//Transmitted Parameters [fragment] = Top//back root anchor point) */?>
Fourth, the use of basename built-in functions
<?php$test = basename ("Http://localhost/index.php?name=tank&sex=1#top"); echo $test;/* results are as follows Index.php?name= Tank&sex=1#top*/?>
In addition, there is a regular matching process to get the desired value. This method is more accurate, the efficiency is not considered ...
Following the development of the practice of regular processing methods:
<?phppreg_match_all ("/(\w+=\w+) (#\w+)?/I", "http://localhost/index.php?" Name=tank&sex=1#top ", $match);p Rint_r ($match);/* The result is the following array ([0] = = Array ([0] = Name=tank [1] = = Sex=1#top) [1] = = Array ([0] = Name=tank [1] = = S Ex=1) [2] = = Array ([0] = [1] = + #top)) */?>