cvs: phpdoc-fr /reference/url/functions http-build-query.xml
| From: | Mehdi Achour | Date: | Mon, 24 Nov 2003 12:13:55 +0000 |
| Subject: | cvs: phpdoc-fr /reference/url/functions http-build-query.xml | ||
| Groups: | php.doc.fr | ||
| Request: | Send a blank email to doc-fr+get-936@lists.php.net to get a copy of this message | ||
didou Mon Nov 24 07:13:55 2003 EDT
Added files:
/phpdoc-fr/reference/url/functions http-build-query.xml
Log:
new translation
Index: phpdoc-fr/reference/url/functions/http-build-query.xml
+++ phpdoc-fr/reference/url/functions/http-build-query.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.0 -->
<refentry id="function.http-build-query">
<refnamediv>
<refname>http_build_query</refname>
<refpurpose>Génère une chaîne de requête en
encodage URL</refpurpose>
</refnamediv>
<refsect1>
<title>Description</title>
<methodsynopsis>
<type>string</type><methodname>http_build_query</methodname>
<methodparam><type>array</type><parameter>formdata</parameter></methodparam>
<methodparam
choice="opt"><type>string</type><parameter>numeric_prefix</parameter></methodparam>
</methodsynopsis>
<simpara>
<function>http_build_query</function> génère une
chaîne en encodage URL,
construite à partir du tableau indexé ou associatif
<parameter>formdata</parameter>. <parameter>formdata</parameter>
peut être un tableau ou un objet contenant une structure
mono-dimensionnelle simple, ou un tableau de tableaux (qui peuvent aussi
contenir des tableaux). Si des indices numériques sont utilisés dans
le tableau de base et que <parameter>numeric_prefix</parameter> est fourni,
il sera utilisé pour préfixer les noms des index pour les
éléments du tableau
de base seulement.
Cela permet de générer des noms de variables valides, si les
données sont
ensuites décodées par &php; ou une application CGI.
</simpara>
<example>
<title>Utilisation simple de
<function>http_build_query</function></title>
<programlisting role="php">
<![CDATA[
<?php
$data = array('foo'=>'bar',
'baz'=>'boom',
'cow'=>'milk',
'php'=>'hypertext processor');
echo http_build_query($data); // foo=bar&baz=boom&cow=milk&php=hypertext+processor
?>
]]>
</programlisting>
</example>
<example>
<title><function>http_build_query</function> avec tableau
indexé.</title>
<programlisting role="php">
<![CDATA[
<?php
$data = array('foo', 'bar', 'baz', 'boom', 'cow'
=> 'milk', 'php' =>'hypertext processor');
echo http_build_query($data);
/* affiche :
0=foo&1=bar&2=baz&3=boom&cow=milk&php=hypertext+processor
*/
echo http_build_query($data, 'myvar_');
/* affiche :
myvar_0=foo&myvar_1=bar&myvar_2=baz&myvar_3=boom&cow=milk&php=hypertext+processor
*/
?>
]]>
</programlisting>
</example>
<example>
<title><function>http_build_query</function> avec tableau
complexe</title>
<programlisting role="php">
<![CDATA[
<?php
$data = array('user'=>array('name'=>'Bob Smith',
'age'=>47,
'sex'=>'M',
'dob'=>'5/12/1956'),
'pastimes'=>array('golf', 'opera', 'poker',
'rap'),
'children'=>array('bobby'=>array('age'=>12,
'sex'=>'M'),
'sally'=>array('age'=>8,
'sex'=>'F')),
'CEO');
echo http_build_query($data, 'flags_');
?>
]]>
</programlisting>
<para>
cet exemple va afficher : (sur plusieurs lignes pour lisibilité)
</para>
<screen>
<![CDATA[
user[name]=Bob+Smith&user[age]=47&user[sex]=M&user[dob]=5%1F12%1F1956&
pastimes[0]=golf&pastimes[1]=opera&pastimes[2]=poker&pastimes[3]=rap&
children[bobby][age]=12&children[bobby][sex]=M&children[sally][age]=8&
children[sally][sex]=F&flags_0=CEO
]]>
</screen>
<para>
<note>
<para>
Seuls les éléments indéxés
numériquement ("CEO") dans le tableau de base
sont préfixés. Les autres indices numériques à
d'autres niveaux n'ont
pas besoins d'être préfixés pour avoir des noms
valides.
</para>
</note>
</para>
</example>
<example>
<title>Utilisation de <function>http_build_query</function> avec un
objet</title>
<programlisting role="php">
<![CDATA[
<?php
class myClass {
var $foo;
var $baz;
function myClass() {
$this->foo = 'bar';
$this->baz = 'boom';
}
}
$data = new myClass();
echo http_build_query($data); // foo=bar&baz=boom
?>
]]>
</programlisting>
</example>
<simpara>
Voir aussi
<function>parse_str</function>,
<function>parse_url</function>,
<function>urlencode</function> et
<function>array_walk</function>.
</simpara>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->