Ec (2); usage: voidparse_str (string $ str [, array & amp; $ arr]) parse_str is used to parse (separate) the query string (QueryString) in the URL ), the query string refers to a URL? What follows, such as localhosttestresult. php? Nameanve & amp; age21, the query string is script ec (2); script
Usage: void parse_str (string $ str [, array & $ arr])
Parse_str is used to parse (separate) the Query String in a URL? What follows, such as http: // localhost/test/result. php? Name = anve & age = 21, the query string is "name = anve & age = 21 ".
Of course, in PHP, you can use the $ _ GET array to obtain the value of the query string, but sometimes parse_str is more convenient, especially when the variable name in the query string (corresponding to the name and age in the above example) is unknown.
Index.html:
Name:
Age:
Result. php:
$ String = $ _ SERVER [''query _ string'']; // use $ _ SERVER [''query _ string''] to obtain the query string.
Echo ''' $ string: ''. $ string .''
'';
Parse_str ($ string );
Echo ''$ name:''. $ name .''
'';
Echo ''$ age:''. $ age .''
''; // After parse_str, two variables $ name and $ age are generated and assigned correctly.
Parse_str ($ string, $ arr); // The second parameter $ arr is an array used to save the results, so that multiple variables are not generated as before.
Echo''
'';
Print_r ($ arr); // $ arr [''name''] and $ arr [''age'] are correctly assigned values.
Echo''
'';
?>
Note: parse_str will automatically perform urldecode (URL Decoding ). For example, enter "bobo" in the name of index.html. My test result is:
</