PHP 4.3.0, 5
Sintatti:
string file_get_contents (
string $file [,
bool $use_include_path [,
resource $context [,
int $offset ]]] )
file_get_contents è una funzione di PHP che memorizza il contenuto del file in un unica stringa, diversamente da come avviene con la funzione
file(); che memorizza le varie righe come elementi di un
array.
Tramite il parametro
$offset (introdotto dal PHP 5.1.0) è possibile specificare da quale numero di carattere cominciare questa "estrazione".
file.txt
Codice PHP:
<?
$file = "file.txt";
$string = file_get_contents ($file);
echo $string; // risultato: abcdefghilm
$string = file_get_contents ($file, 2); // impostiamo un offset
echo $string; // risultato: cdefghilm
?>