Funzione PHP file()
❮ Riferimento al file system PHPEsempio
Leggi un file in un array:
<?php
print_r(file("test.txt"));
?>
Definizione e utilizzo
Il file() legge un file in un array.
Ogni elemento dell'array contiene una riga del file, con il carattere di nuova riga ancora allegato.
Sintassi
file(filename, flag, context)
Valori dei parametri
Parameter | Description |
---|---|
filename | Required. Specifies the path to the file to read |
flag |
Optional. Can be one or more of the following constants:
|
context | Optional. Specifies the context of the file handle. Context is a set of options that can modify the behavior of a stream. Can be skipped by using NULL. |
Dettagli tecnici
Valore di ritorno: | L'intero file in un array, FALSE in caso di errore |
---|---|
Versione PHP: | 4.0+ |
Cassaforte binaria: | Sì, in PHP 4.3 |
❮ Riferimento al file system PHP