file_get_contents

(PHP 4 >= 4.3.0, PHP 5)

file_get_contents -- Reads entire file into a string

Description

string file_get_contents ( string filename [, bool use_include_path [, resource context [, int offset [, int maxlen]]]] )

Identical to file(), except that file_get_contents() returns the file in a string, starting at the specified offset up to maxlen bytes. On failure, file_get_contents() will return FALSE.

file_get_contents() is the preferred way to read the contents of a file into a string. It will use memory mapping techniques if supported by your OS to enhance performance.

Huomaa: If you're opening a URI with special characters, such as spaces, you need to encode the URI with urlencode().

ChangeLog

VersionDescription
5.0.0 Added the context support.
5.1.0 Added the offset and maxlen parameters.

Notes

Huomaa: T�m� funktio osaa k�sitell� my�s bin��rimuotoista dataa.

Vihje: T�m�n funktion kanssa voit k�ytt�� my�s URLia tiedostonimen sijaan jos "fopen wrappers" on kytketty p��lle. Katso funktiosta fopen() lis�tietoa tuetuista URL-protokollista ja siit� kuinka tiedoston nimi m��ritell��n Liite L.

Varoitus

Some non-standard compliant webservers, such as IIS, send data in a way that causes PHP to raise warnings. When working with such servers you should lower your error_reporting level not to include warnings.

See Also

file()
fgets()
fread()
readfile()
file_put_contents()