reference/url/functions/http-build-query.xml
c1413dcaa87de5d9954e5ed90f3612993b7cb12c
...
...
@@ -10,10 +10,10 @@
10
10
&reftitle.description;
11
11
<methodsynopsis>
12
12
<type>string</type><methodname>http_build_query</methodname>
13
-
<methodparam><type>mixed</type><parameter>query_data</parameter></methodparam>
14
-
<methodparam choice="opt"><type>string</type><parameter>numeric_prefix</parameter></methodparam>
15
-
<methodparam choice="opt"><type>string</type><parameter>arg_separator</parameter></methodparam>
16
-
<methodparam choice="opt"><type>int</type><parameter>enc_type</parameter><initializer><constant>PHP_QUERY_RFC1738</constant></initializer></methodparam>
13
+
<methodparam><type class="union"><type>array</type><type>object</type></type><parameter>data</parameter></methodparam>
14
+
<methodparam choice="opt"><type>string</type><parameter>numeric_prefix</parameter><initializer>""</initializer></methodparam>
15
+
<methodparam choice="opt"><type class="union"><type>string</type><type>null</type></type><parameter>arg_separator</parameter><initializer>&null;</initializer></methodparam>
16
+
<methodparam choice="opt"><type>int</type><parameter>encoding_type</parameter><initializer><constant>PHP_QUERY_RFC1738</constant></initializer></methodparam>
17
17
</methodsynopsis>
18
18
<para>
19
19
Generates a URL-encoded query string from the associative (or indexed)
...
...
@@ -26,18 +26,18 @@
26
26
<para>
27
27
<variablelist>
28
28
<varlistentry>
29
-
<term><parameter>query_data</parameter></term>
29
+
<term><parameter>data</parameter></term>
30
30
<listitem>
31
31
<para>
32
32
May be an array or object containing properties.
33
33
</para>
34
34
<para>
35
-
If <parameter>query_data</parameter> is an array, it may be a simple
35
+
If <parameter>data</parameter> is an array, it may be a simple
36
36
one-dimensional structure, or an array of arrays (which in
37
37
turn may contain other arrays).
38
38
</para>
39
39
<para>
40
-
If <parameter>query_data</parameter> is an object, then only public
40
+
If <parameter>data</parameter> is an object, then only public
41
41
properties will be incorporated into the result.
42
42
</para>
43
43
</listitem>
...
...
@@ -60,27 +60,27 @@
60
60
<term><parameter>arg_separator</parameter></term>
61
61
<listitem>
62
62
<para>
63
+
The argument separator. If not set or &null;,
63
64
<link linkend="ini.arg-separator.output">arg_separator.output</link>
64
-
is used to separate arguments but may be overridden by specifying
65
-
this parameter.
65
+
is used to separate arguments.
66
66
</para>
67
67
</listitem>
68
68
</varlistentry>
69
69
<varlistentry>
70
-
<term><parameter>enc_type</parameter></term>
70
+
<term><parameter>encoding_type</parameter></term>
71
71
<listitem>
72
72
<para>
73
73
By default, <constant>PHP_QUERY_RFC1738</constant>.
74
74
</para>
75
75
<para>
76
-
If <parameter>enc_type</parameter> is
76
+
If <parameter>encoding_type</parameter> is
77
77
<constant>PHP_QUERY_RFC1738</constant>, then encoding is performed per
78
78
<link xlink:href="&url.rfc;1738">RFC 1738</link> and the
79
79
<literal>application/x-www-form-urlencoded</literal> media type, which
80
80
implies that spaces are encoded as plus (<literal>+</literal>) signs.
81
81
</para>
82
82
<para>
83
-
If <parameter>enc_type</parameter> is
83
+
If <parameter>encoding_type</parameter> is
84
84
<constant>PHP_QUERY_RFC3986</constant>, then encoding is performed
85
85
according to <link xlink:href="&url.rfc;3986">RFC 3986</link>, and
86
86
spaces will be percent encoded (<literal>%20</literal>).
...
...
@@ -100,38 +100,24 @@
100
100

101
101
<refsect1 role="changelog">
102
102
&reftitle.changelog;
103
-
<para>
104
-
<informaltable>
105
-
<tgroup cols="2">
106
-
<thead>
107
-
<row>
108
-
<entry>&Version;</entry>
109
-
<entry>&Description;</entry>
110
-
</row>
111
-
</thead>
112
-
<tbody>
113
-
<row>
114
-
<entry>5.4.0</entry>
115
-
<entry>
116
-
The <parameter>enc_type</parameter> parameter was added.
117
-
</entry>
118
-
</row>
119
-
<row>
120
-
<entry>5.1.3</entry>
121
-
<entry>
122
-
Square brackets are escaped.
123
-
</entry>
124
-
</row>
125
-
<row>
126
-
<entry>5.1.2</entry>
127
-
<entry>
128
-
The <parameter>arg_separator</parameter> parameter was added.
129
-
</entry>
130
-
</row>
131
-
</tbody>
132
-
</tgroup>
133
-
</informaltable>
134
-
</para>
103
+
<informaltable>
104
+
<tgroup cols="2">
105
+
<thead>
106
+
<row>
107
+
<entry>&Version;</entry>
108
+
<entry>&Description;</entry>
109
+
</row>
110
+
</thead>
111
+
<tbody>
112
+
<row>
113
+
<entry>8.0.0</entry>
114
+
<entry>
115
+
<parameter>arg_separator</parameter> is now nullable.
116
+
</entry>
117
+
</row>
118
+
</tbody>
119
+
</tgroup>
120
+
</informaltable>
135
121
</refsect1>
136
122

137
123
<refsect1 role="examples">
...
...
@@ -141,10 +127,13 @@
141
127
<programlisting role="php">
142
128
<![CDATA[
143
129
<?php
144
-
$data = array('foo'=>'bar',
145
-
'baz'=>'boom',
146
-
'cow'=>'milk',
147
-
'php'=>'hypertext processor');
130
+
$data = array(
131
+
'foo' => 'bar',
132
+
'baz' => 'boom',
133
+
'cow' => 'milk',
134
+
'null' => null,
135
+
'php' => 'hypertext processor'
136
+
);
148
137

149
138
echo http_build_query($data) . "\n";
150
139
echo http_build_query($data, '', '&amp;');
...
...
@@ -166,7 +155,7 @@ foo=bar&amp;baz=boom&amp;cow=milk&amp;php=hypertext+processor
166
155
<programlisting role="php">
167
156
<![CDATA[
168
157
<?php
169
-
$data = array('foo', 'bar', 'baz', 'boom', 'cow' => 'milk', 'php' =>'hypertext processor');
158
+
$data = array('foo', 'bar', 'baz', null, 'boom', 'cow' => 'milk', 'php' => 'hypertext processor');
170
159

171
160
echo http_build_query($data) . "\n";
172
161
echo http_build_query($data, 'myvar_');
...
...
@@ -176,8 +165,8 @@ echo http_build_query($data, 'myvar_');
176
165
&example.outputs;
177
166
<screen>
178
167
<![CDATA[
179
-
0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor
180
-
myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor
168
+
0=foo&1=bar&2=baz&4=boom&cow=milk&php=hypertext+processor
169
+
myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_4=boom&cow=milk&php=hypertext+processor
181
170
]]>
182
171
</screen>
183
172
</example>
...
...
@@ -186,23 +175,27 @@ myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processo
186
175
<programlisting role="php">
187
176
<![CDATA[
188
177
<?php
189
-
$data = array('user'=>array('name'=>'Bob Smith',
190
-
'age'=>47,
191
-
'sex'=>'M',
192
-
'dob'=>'5/12/1956'),
193
-
'pastimes'=>array('golf', 'opera', 'poker', 'rap'),
194
-
'children'=>array('bobby'=>array('age'=>12,
195
-
'sex'=>'M'),
196
-
'sally'=>array('age'=>8,
197
-
'sex'=>'F')),
198
-
'CEO');
178
+
$data = array(
179
+
'user' => array(
180
+
'name' => 'Bob Smith',
181
+
'age' => 47,
182
+
'sex' => 'M',
183
+
'dob' => '5/12/1956'
184
+
),
185
+
'pastimes' => array('golf', 'opera', 'poker', 'rap'),
186
+
'children' => array(
187
+
'bobby' => array('age'=>12, 'sex'=>'M'),
188
+
'sally' => array('age'=>8, 'sex'=>'F')
189
+
),
190
+
'CEO'
191
+
);
199
192

200
193
echo http_build_query($data, 'flags_');
201
194
?>
202
195
]]>
203
196
</programlisting>
204
197
<para>
205
-
this will output : (word wrapped for readability)
198
+
The above example will output: (word wrapped for readability)
206
199
</para>
207
200
<screen>
208
201
<![CDATA[
...
...
@@ -233,9 +226,9 @@ class parentClass {
233
226
public $pub = 'publicParent';
234
227
protected $prot = 'protectedParent';
235
228
private $priv = 'privateParent';
236
-
public $pub_bar = Null;
237
-
protected $prot_bar = Null;
238
-
private $priv_bar = Null;
229
+
public $pub_bar = null;
230
+
protected $prot_bar = null;
231
+
private $priv_bar = null;
239
232

240
233
public function __construct(){
241
234
$this->pub_bar = new childClass();
...
...
@@ -278,7 +271,6 @@ pub=publicParent&pub_bar%5Bpub%5D=publicChild
278
271
</refsect1>
279
272

280
273
</refentry>
281
-

282
274
<!-- Keep this comment at the end of the file
283
275
Local variables:
284
276
mode: sgml
285
277