Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 16
Filesystem updated reference/filesystem/functions/file.xml#68
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Uh oh!
There was an error while loading. Please reload this page.
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
4540819
updated reference/filesystem/functions/file.xml
ManueldG 5fca991
Fix build (#64)
DavidePastore 11b97b5
Merge branch 'filesystem' into fixing-file
ManueldG 921b85b
fix credits and comments
ManueldG 6eeb343
corrections from Davide Pastore
ManueldG 88e4a52
Update file.xml
ManueldG 15abe0f
Merge branch 'filesystem' of https://github.com/ManueldG/doc-it into …
ManueldG 4da6a53
minor corrections file.xml
ManueldG f3c787f
Merge branch 'master' into filesystem
ManueldG cfeec26
Update file.xml
ManueldG f549dcb
Update file.xml fixed example
ManueldG c7244bf
Update file.xml "puoi" substituted with "è possibile"
ManueldG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,76 +1,207 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- EN-Revision: n/a Maintainer: fernando Status: working --> | ||
| <!-- CREDITS: cortesi --> | ||
| <refentry xml:id="function.file" xmlns="http://docbook.org/ns/docbook"> | ||
| <refnamediv> | ||
| <refname>file</refname> | ||
| <refpurpose>Legge l'intero file in un vettore</refpurpose> | ||
| </refnamediv> | ||
| <refsect1> | ||
| <title>Descrizione</title> | ||
| <methodsynopsis> | ||
| <type>array</type><methodname>file</methodname> | ||
| <methodparam><type>string</type><parameter>filename</parameter></methodparam> | ||
| <methodparam choice="opt"><type>int</type><parameter>use_include_path</parameter></methodparam> | ||
| <methodparam choice="opt"><type>resource</type><parameter>context</parameter></methodparam> | ||
| </methodsynopsis> | ||
| <para> | ||
| Identica a <function>readfile</function>, eccetto per il fatto che | ||
| <function>file</function> restituisce il file in un vettore. Ogni | ||
| elemento del vettore corrisponde ad una riga del file, con il carattere di | ||
| newline ancora inserito. Se la funzione non riesce restituisce | ||
| &false;. | ||
| </para> | ||
| <para> | ||
| Puoi impostare il secondo parametro, <parameter>use_include_path</parameter>, (opzionale) ad "1", | ||
| se vuoi cercare il file nel <link | ||
| linkend="ini.include-path">include_path</link>. | ||
| </para> | ||
| <para> | ||
| <informalexample> | ||
| <programlisting role="php"> | ||
| <?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 | ||
ManueldG marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| 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 una pagina web in un array e la stampa. In questo esempio useremo il protocollo | ||
| // HTTP per ottenere il sorgente di un URL | ||
| // inserisce un file in un array e lo stampa. In questo esempio useremo il protocollo | ||
| // HTTP per ottenere il sorgente HTML di un URL | ||
ManueldG marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $lines = file('http://www.example.com/'); | ||
| // Ciclo attraverso l'array, si visualizzerà il sorgente come html ed i numeri di linea | ||
| foreach($lines as $line_num => $line) { | ||
| //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"; | ||
| } | ||
| // Un'altro esempio, inserisce la pagina web in una stringa. Vedere anche file_get_contents(). | ||
| $html = implode('', file ('http://www.example.com/')); | ||
| //Utilizzo del parametro flag opzionale | ||
ManueldG marked this conversation as resolved.
Uh oh!There was an error while loading. Please reload this page. | ||
| $trimmed = file('somefile.txt', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); | ||
| ?> | ||
| ]]> | ||
| </programlisting> | ||
| </informalexample> | ||
| </para> | ||
| &tip.fopen-wrapper; | ||
| <note> | ||
| <para> | ||
| Ciascuna riga dell'array restituito conterrà il carattere di fine riga, occorre, pertanto, | ||
| utilizzare <function>rtrim</function> se si desidera rimuovere il carattere | ||
| di fine riga. | ||
| </para> | ||
| </note> | ||
| ¬e.line-endings; | ||
| <note> | ||
| <para> | ||
| A partire da PHP 4.3.0 si può utilizzare <function>file_get_contents</function> per | ||
| memorizzare il contenuto di un file in una stringa in formato binario. | ||
| </para> | ||
| </note> | ||
| ¬e.context-support; | ||
| &warn.ssl-non-standard; | ||
| <para> | ||
| Vedere anche <function>readfile</function>, | ||
| <function>fopen</function>, <function>fsockopen</function>, | ||
| <function>popen</function>, <function>file_get_contents</function> e | ||
| <function>include</function>. | ||
| </para> | ||
| </refsect1> | ||
| </refentry> | ||
| </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: | ||
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.