mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-29 04:12:21 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@274184 c90b9560-bf6c-de11-be94-00142212c4b1
226 lines
6.0 KiB
XML
226 lines
6.0 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.22 $ -->
|
|
<!-- EN-Revision: 1.20 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
|
|
<refentry xml:id="function.parse-url" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>parse_url</refname>
|
|
<refpurpose>Analyse une URL et retourne ses composants</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>mixed</type><methodname>parse_url</methodname>
|
|
<methodparam><type>string</type><parameter>url</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>component</parameter><initializer>-1</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Cette fonction analyse une URL et retourne un tableau associatif contenant
|
|
tous les éléments qui y sont présents.
|
|
</para>
|
|
<para>
|
|
Cette fonction n'est <emphasis role="strong">pas</emphasis>
|
|
faite pour valider l'URL fournie, elle ne fait que la découper en parties listées
|
|
ci-dessous. Les URL partielles sont également acceptées, la fonction
|
|
<function>parse_url</function> fera de son mieux pour les analyser correctement.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>url</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
L'URL à analyser. Les caractères invalides sont remplacées par
|
|
des caractères soulignés <literal>_</literal>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>component</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Peut être une des constantes parmi <constant>PHP_URL_SCHEME</constant>,
|
|
<constant>PHP_URL_HOST</constant>, <constant>PHP_URL_PORT</constant>,
|
|
<constant>PHP_URL_USER</constant>, <constant>PHP_URL_PASS</constant>,
|
|
<constant>PHP_URL_PATH</constant>, <constant>PHP_URL_QUERY</constant>
|
|
ou <constant>PHP_URL_FRAGMENT</constant> pour récupérer uniquement
|
|
une partie de l'URL en tant que chaîne de caractères.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Pour les URL vraiment mal formées, <function>parse_url</function> peut retourner
|
|
&false; et émettre un <constant>E_WARNING</constant>. Sinon, un tableau associatif
|
|
est retourné, dont les éléments peuvent être (au moins un) :
|
|
<itemizedlist>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">scheme</varname> - e.g. http
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">host</varname>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">port</varname>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">user</varname>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">pass</varname>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">path</varname>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">query</varname> - après le marqueur de question <literal>?</literal>
|
|
</simpara>
|
|
</listitem>
|
|
<listitem>
|
|
<simpara>
|
|
<varname remap="structfield">fragment</varname> - après la hachure <literal>#</literal>
|
|
</simpara>
|
|
</listitem>
|
|
</itemizedlist>
|
|
</para>
|
|
<para>
|
|
Si le paramètre <parameter>component</parameter> est spécifié, une &string;
|
|
est retournée au lieu d'un &array;.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<para>
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>5.1.2</entry>
|
|
<entry>Ajout du paramètre <parameter>component</parameter></entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>parse_url</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$url = 'http://username:password@hostname/path?arg=value#anchor';
|
|
|
|
print_r(parse_url($url));
|
|
|
|
echo parse_url($url, PHP_URL_PATH);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Array
|
|
(
|
|
[scheme] => http
|
|
[host] => hostname
|
|
[user] => username
|
|
[pass] => password
|
|
[path] => /path
|
|
[query] => arg=value
|
|
[fragment] => anchor
|
|
)
|
|
/path
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
<note>
|
|
<para>
|
|
Cette fonction ne fonctionne pas avec les URL relatives.
|
|
</para>
|
|
</note>
|
|
<note>
|
|
<para>
|
|
<function>parse_url</function> a été créée tout spécialement pour analyser les URL
|
|
et non les URI. Cependant, pour des raisons de compatibilité adjacente, PHP
|
|
fait une exception pour le schéma <literal>file://</literal> où les triples slashs
|
|
(<literal>file:///</literal>...) sont autorisés. Tous les autres schémas sont invalides.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>pathinfo</function></member>
|
|
<member><function>parse_str</function></member>
|
|
<member><function>http_build_query</function></member>
|
|
<member><function>dirname</function></member>
|
|
<member><function>basename</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</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
|
|
--> |