http_build_query
Function • Params and return types changed in PHP 8.0
Generate URL-encoded query string.
http_build_query Function synopsis
http_build_query(
object|array $data,
string $numeric_prefix = "",
?string $arg_separator = null,
int $encoding_type = PHP_QUERY_RFC1738
): string
Parameters
$data
Typeobject|array
May be an array or object containing properties.
$numeric_prefix
OptionalTypestringDefault value""
If numeric indices are used in the base array and this parameter is provided, it will be prepended to the numeric index for elements in the base array only.
$arg_separator
OptionalType?stringDefault valuenull
The argument separator. If not set or null,
arg_separator.output is used to separate arguments.
$encoding_type
OptionalTypeintDefault valuePHP_QUERY_RFC1738
By default, PHP_QUERY_RFC1738.
Return value
Typestring
Returns a URL-encoded string.
Changes to the http_build_query Function
PHP 8.0
- Return type added:
string - Parameter name of parameter #1 changed:
$formdatato$data - Parameter type added for parameter #1 (
$data):object|array - Parameter name of parameter #2 changed:
$prefixto$numeric_prefix - Parameter type added for parameter #2 (
$numeric_prefix):string - Parameter default value added for position #2 (
$numeric_prefix):"" - Parameter type added for parameter #3 (
$arg_separator):?string - Parameter default value added for position #3 (
$arg_separator):null - Parameter name of parameter #4 changed:
$enc_typeto$encoding_type - Parameter type added for parameter #4 (
$encoding_type):int - Parameter default value added for position #4 (
$encoding_type):PHP_QUERY_RFC1738
http_build_query(
- $formdata,
+ object|array $data,
- $prefix,
+ string $numeric_prefix = "",
- $arg_separator,
+ ?string $arg_separator = null,
- $enc_type
+ int $encoding_type = PHP_QUERY_RFC1738
- )
+ ): string PHP 5.4
- Optional parameter added - #4:
$enc_type
http_build_query(
$formdata,
$prefix,
- $arg_separator
+ $arg_separator,
+ $enc_type
) http_build_query Function Availability
http_build_query Function Availability| PHP Version | Availability |
|---|---|
| PHP 8.6Upcoming Release | Yes |
| PHP 8.5Supported (Latest) | Yes |
| PHP 8.4Supported | Yes |
| PHP 8.3Security-Fixes Only | Yes |
| PHP 8.2Security-Fixes Only | Yes |
| PHP 8.1Unsupported | Yes |
| PHP 8.0Unsupported | Yes |
| PHP 7.4Unsupported | Yes |
| PHP 7.3Unsupported | Yes |
| PHP 7.2Unsupported | Yes |
| PHP 7.1Unsupported | Yes |
| PHP 7.0Unsupported | Yes |
| PHP 5.6Unsupported | Yes |
| PHP 5.5Unsupported | Yes |
| PHP 5.4Unsupported | Yes |
| PHP 5.3Unsupported | Yes |