The function parse_str()
automatically reads all query parameters into an array.
For example, if the URL is http://www.example.com/page.php?x=100&y=200
, the code
$queries = array();
parse_str($_SERVER['QUERY_STRING'], $queries);
will store parameters into the $queries
array ($queries['x']=100
, $queries['y']=200
).
Look at documentation of parse_str
EDIT
According to the PHP documentation, parse_str()
should only be used with a second parameter. Using parse_str($_SERVER['QUERY_STRING'])
on this URL will create variables $x
and $y
, which makes the code vulnerable to attacks such as http://www.example.com/page.php?authenticated=1
.