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.
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.
Warning
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.
Return Values
No value is returned.
Changelog
Version
Description
8.0.0
result is no longer optional.
7.2.0
Usage of parse_str() without a second parameter
now emits an E_DEPRECATED notice.
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() 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.
Note:
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().