Описание тега file-get-contents
In PHP, 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.
In PHP, file_get_contents
is used to read an entire file into a single string. Depending on the server configuration, it can also be used to read URLs as well. It differs from file()
, in that file
is designed to return a resource pointer and then used read the file in chunks (i.e. CSV files). Use file
for large files that should not be read all at once. Use file_get_contents
to read smaller files and files that cannot be read as easily read in chunks (i.e. JSON)
For more details see the PHP manual entry.