file_get_contents
Reads entire file into a string. This is the preferred way to read the contents of a file into a string.
Parameters
main.php
Return Values
string|false
Returns the read data as a string, or false on failure
On success:String containing the file contents
On failure:false if the file cannot be read or doesn't exist
Notes
- Can read both local files and remote URLs (if allow_url_fopen is enabled)
- Use memory mapping techniques when supported for enhanced performance
- Binary-safe function that preserves null bytes and special characters
- Offset parameter allows reading from specific position in file
Changelog
- 8.0.0: maxlen is now nullable
- 7.1.0: Support for negative offsets
Related Functions
pathinfo
File SystemReturns information about a file path including directory, basename, extension, and filename.
filepathextension
file_put_contents
File SystemWrites data to a file. This is the preferred way to write data to a file as it handles opening, writing, and closing automatically.
writefilesave