Changed the data paramater from $formdata to $query_data

Documented that only public properties are accessed.
Updated example to show nested objects.
Fix bug#52638

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@302467 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Richard Quadling 2010-08-19 09:28:50 +00:00
parent 9f7e2da29b
commit 7c26f3dfe5

View file

@ -10,7 +10,7 @@
&reftitle.description;
<methodsynopsis>
<type>string</type><methodname>http_build_query</methodname>
<methodparam><type>array</type><parameter>formdata</parameter></methodparam>
<methodparam><type>mixed</type><parameter>query_data</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>numeric_prefix</parameter></methodparam>
<methodparam choice="opt"><type>string</type><parameter>arg_separator</parameter></methodparam>
</methodsynopsis>
@ -25,14 +25,19 @@
<para>
<variablelist>
<varlistentry>
<term><parameter>formdata</parameter></term>
<term><parameter>query_data</parameter></term>
<listitem>
<para>
May be an array or object containing properties.
</para>
<para>
The array form may be a simple one-dimensional structure, or an array
of arrays (who in turn may contain other arrays).
If <parameter>query_data</parameter> is an array, it may be a simple
one-dimensional structure, or an array of arrays (which in
turn may contain other arrays).
</para>
<para>
If <parameter>query_data</parameter> is an object, then only public
properties will be incorporated into the result.
</para>
</listitem>
</varlistentry>
@ -113,12 +118,19 @@ $data = array('foo'=>'bar',
'cow'=>'milk',
'php'=>'hypertext processor');
echo http_build_query($data); // foo=bar&baz=boom&cow=milk&php=hypertext+processor
echo http_build_query($data, '', '&amp;'); // foo=bar&amp;baz=boom&amp;cow=milk&amp;php=hypertext+processor
echo http_build_query($data) . "\n";
echo http_build_query($data, '', '&amp;');
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
foo=bar&baz=boom&cow=milk&php=hypertext+processor
foo=bar&amp;baz=boom&amp;cow=milk&amp;php=hypertext+processor
]]>
</screen>
</example>
<example>
@ -189,23 +201,39 @@ children%5Bsally%5D%5Bsex%5D=F&flags_0=CEO
<programlisting role="php">
<![CDATA[
<?php
class myClass {
var $foo;
var $baz;
class parentClass {
public $pub = 'publicParent';
protected $prot = 'protectedParent';
private $priv = 'privateParent';
public $pub_bar = Null;
protected $prot_bar = Null;
private $priv_bar = Null;
function myClass() {
$this->foo = 'bar';
$this->baz = 'boom';
public function __construct(){
$this->pub_bar = new childClass();
$this->prot_bar = new childClass();
$this->priv_bar = new childClass();
}
}
$data = new myClass();
class childClass {
public $pub = 'publicChild';
protected $prot = 'protectedChild';
private $priv = 'privateChild';
}
echo http_build_query($data); // foo=bar&baz=boom
$parent = new parentClass();
echo http_build_query($parent);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
pub=publicParent&pub_bar%5Bpub%5D=publicChild
]]>
</screen>
</example>
</refsect1>