http_build_query使用使用

该函数将数组生成一个经过 URL-encode 的请求字符串。

http_build_query ( mixed $query_data [, string $numeric_prefix [, string $arg_separator [, int $enc_type = PHP_QUERY_RFC1738 ]]] )

重点:enc_type是编码类型:PHP_QUERY_RFC1738,PHP_QUERY_RFC3986

默认使用的是PHP_QUERY_RFC1738。

PHP_QUERY_RFC1738,则编码将会以 » RFC 1738 标准和 application/x-www-form-urlencoded 媒体类型进行编码,空格会被编码成加号(+)。

PHP_QUERY_RFC3986,将根据 » RFC 3986 编码,空格会被百分号编码(%20)。

你可能感兴趣的:(php)