mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-24 17:02:18 +01:00
196 lines
5.4 KiB
XML
196 lines
5.4 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: 2957432ebc5ba2770805c08d5c867543ced8dd85 Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: yes -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.file">
|
|
<refnamediv>
|
|
<refname>file</refname>
|
|
<refpurpose>Lit le fichier et renvoie le résultat dans un tableau</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type class="union"><type>array</type><type>false</type></type><methodname>file</methodname>
|
|
<methodparam><type>string</type><parameter>filename</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
|
|
<methodparam choice="opt"><type class="union"><type>resource</type><type>null</type></type><parameter>context</parameter><initializer>&null;</initializer></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Lit le fichier et renvoie le résultat dans un tableau.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Vous pouvez utiliser la fonction <function>file_get_contents</function>
|
|
pour retourner le contenu d'un fichier dans une &string;.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Chemin vers le fichier.
|
|
</para>
|
|
&tip.fopen-wrapper;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Le paramètre optionnel <parameter>flags</parameter> peut être
|
|
une ou plusieurs des constantes suivantes :
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_USE_INCLUDE_PATH</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Recherche le fichier dans l'<link linkend="ini.include-path">include_path</link>.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_IGNORE_NEW_LINES</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
N'ajoute pas de nouvelle ligne à la fin de chaque élément du tableau.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_SKIP_EMPTY_LINES</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Ignore les lignes vides.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_NO_DEFAULT_CONTEXT</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
N'utilise pas le contexte par défaut.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>context</parameter></term>
|
|
<listitem>
|
|
¬e.context-support;
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retourne le fichier dans un tableau.
|
|
Chaque élément du tableau correspond à une ligne du fichier,
|
|
et les retours-chariot sont placés en fin de ligne. Si une erreur
|
|
survient, <function>file</function> retournera &false;.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Chaque ligne du tableau résultant inclura une fin de ligne, à moins
|
|
que <constant>FILE_IGNORE_NEW_LINES</constant> soit utilisé.
|
|
</para>
|
|
</note>
|
|
¬e.line-endings;
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<para>
|
|
Émet une erreur de niveau <constant>E_WARNING</constant> si le fichier
|
|
n'existe pas.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>file</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// Lit une page web dans un tableau.
|
|
$lines = file('http://www.example.com/');
|
|
|
|
// Affiche toutes les lignes du tableau comme code HTML, avec les numéros de ligne
|
|
foreach ($lines as $line_num => $line) {
|
|
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
|
|
}
|
|
|
|
// Utilisation de drapeau
|
|
$trimmed = file('somefile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="notes">
|
|
&reftitle.notes;
|
|
&warn.ssl-non-standard;
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>file_get_contents</function></member>
|
|
<member><function>readfile</function></member>
|
|
<member><function>fopen</function></member>
|
|
<member><function>fsockopen</function></member>
|
|
<member><function>popen</function></member>
|
|
<member><function>include</function></member>
|
|
<member><function>stream_context_create</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:"~/.phpdoc/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
|
|
-->
|