parse_strParse a string as a URL query string
&reftitle.description;
voidparse_strstringstringarrayresult
Parses string as if it were the query string
passed via a URL and sets keys in the provided result
array. If no result is passed, values are instead
set as variables in the current scope.
&reftitle.parameters;
string
The input string.
result
A variable passed by reference, which will be set to an array
containing the key-value pairs extracted from string.
If the result parameter is not passed,
a separate variable is set in the local scope for each key.
Using this function without the result parameter is highly
DISCOURAGED and DEPRECATED as of PHP 7.2.
As of PHP 8.0.0, the result parameter is mandatory.
&reftitle.returnvalues;
&return.void;
&reftitle.changelog;
&Version;&Description;8.0.0result is no longer optional.
7.2.0
Usage of parse_str without a second parameter
now emits an E_DEPRECATED notice.
&reftitle.examples;
Using parse_str
]]>
Any spaces and dots in parameter names are converted to underscores
when creating array keys or local variables.
This is because variable names in PHP are not allowed to contain spaces
or dots, but applies even when using this function with the recommended
result parameter.
parse_str name mangling
]]>
&reftitle.notes;
parse_str is affected by the max_input_vars
directive. Exceeding this limit triggers an E_WARNING,
and any variables beyond the limit are not added to the result array.
The default is 1000; adjust max_input_vars as needed.
All values populated in the result array
(or variables created if second parameter is not set)
are already URL-decoded using the same rules as urldecode.
To get the query string of the current request, you may use the variable
$_SERVER['QUERY_STRING'].
Also, you may want to read the section on
variables from external
sources.
&reftitle.seealso;
parse_urlpathinfohttp_build_queryurldecode