mirror of
https://github.com/php/doc-it.git
synced 2026-03-26 00:22:14 +01:00
* updated reference/filesystem/functions/file.xml * Fix build (#64) * Update oop5.xml * Update types.xml * Update fgetcsv.xml * Update bcdiv.xml * Update bcadd.xml and gmp-init.xml * Update ini.xml * Remove a file not in the EN tree * Fix credits section * Update get-magic-quotes-runtime.xml * Remove useless section * Update addslashes.xml * Update ini.core.xml * Update fwrite.xml * Remove ini.magic-quotes-gpc reference from language-snippets.ent * Update stripslashes.xml * Update parse-str.xml * Update oci-bind-by-name.xml * Merge branch 'filesystem' into fixing-file * fix credits and comments * corrections from Davide Pastore * Update file.xml * minor corrections file.xml * Update file.xml * Update file.xml fixed example * Update file.xml "puoi" substituted with "è possibile" --------- Co-authored-by: Davide Pastore <pasdavide@gmail.com>
226 lines
6.1 KiB
XML
226 lines
6.1 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- EN-Revision: e3ae86b439c1963f0cd6d262712e2d3f7e85bc37 Maintainer: ManueldG Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
<!-- CREDITS: cortesi -->
|
|
<!-- CREDITS: fernando -->
|
|
<refentry xmlns="http://docbook.org/ns/docbook" xml:id="function.file">
|
|
<refnamediv>
|
|
<refname>file</refname>
|
|
<refpurpose>Legge l'intero file in un array</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>
|
|
Legge l'intero file in un array.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
In alternativa è possibile usare <function>file_get_contents</function> per estrarre il contenuto
|
|
di un file sotto forma di stringa.
|
|
</para>
|
|
</note>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>filename</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Percorso del file.
|
|
</para>
|
|
&tip.fopen-wrapper;
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Il parametro opzionale <parameter>flags</parameter> può essere uno, o
|
|
più valori, delle seguenti costanti:
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_USE_INCLUDE_PATH</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Cerca il file in <link
|
|
linkend="ini.include-path">include_path</link>.
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_IGNORE_NEW_LINES</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Ometterà newline alla fine di ogni elemento dell'array
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_SKIP_EMPTY_LINES</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Salta le righe vuote
|
|
</simpara>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term>
|
|
<constant>FILE_NO_DEFAULT_CONTEXT</constant>
|
|
</term>
|
|
<listitem>
|
|
<simpara>
|
|
Non usa il context di default
|
|
</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>
|
|
Restituisce il file in un array. Ogni elemento dell'array corrisponde a una
|
|
riga nel file, con newline incluso. In caso di errore,
|
|
<function>file</function> restituisce &false;.
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Per ogni linea riportata nell'array risultante includerà newline, a meno
|
|
che non venga usato <constant>FILE_IGNORE_NEW_LINES</constant>.
|
|
</para>
|
|
</note>
|
|
¬e.line-endings;
|
|
</refsect1>
|
|
|
|
<refsect1 role="errors">
|
|
&reftitle.errors;
|
|
<simpara>
|
|
A partire da PHP 8.3.0, genera un <exceptionname>ValueError</exceptionname>
|
|
se <parameter>flags</parameter> include valori non validi, come
|
|
<constant>FILE_APPEND</constant>.
|
|
</simpara>
|
|
<para>
|
|
Emette un <constant>E_WARNING</constant> a livello d'errore
|
|
se il file non esiste.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="changelog">
|
|
&reftitle.changelog;
|
|
<informaltable>
|
|
<tgroup cols="2">
|
|
<thead>
|
|
<row>
|
|
<entry>&Version;</entry>
|
|
<entry>&Description;</entry>
|
|
</row>
|
|
</thead>
|
|
<tbody>
|
|
<row>
|
|
<entry>8.3.0</entry>
|
|
<entry>
|
|
<exceptionname>ValueError</exceptionname> viene generato
|
|
per qualunque valore di <parameter>flags</parameter> non valido.
|
|
</entry>
|
|
</row>
|
|
</tbody>
|
|
</tgroup>
|
|
</informaltable>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Esempio di <function>file</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
// inserisce un file in un array e lo stampa. In questo esempio useremo il protocollo
|
|
// HTTP per ottenere il sorgente HTML di un URL
|
|
$lines = file('http://www.example.com/');
|
|
//Itera attraverso quest'array, mostra il sorgente HTML così com'è e anche i numeri di riga.
|
|
|
|
foreach ($lines as $line_num => $line) {
|
|
echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />\n";
|
|
}
|
|
|
|
//Utilizzo del parametro flag opzionale
|
|
$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
|
|
-->
|