$files->fileGetContents() method

Get contents of file

This is the same as PHP’s file_get_contents() except that the arguments are simpler and it may be preferable to use this in ProcessWire for future cases where the file system may be abstracted from the installation.

Available since version 3.0.167.


// basic usage
$bool = $files->fileGetContents(string $filename);

// usage with all arguments
$bool = $files->fileGetContents(string $filename, int $offset = 0, int $maxlen = 0);



Full path and filename to read

offset (optional)int

The offset where the reading starts on the original stream. Negative offsets count from the end of the stream.

maxlen (optional)int

Maximum length of data read. The default is to read until end of file is reached.

Return value

bool string

Returns the read data (string) or boolean false on failure.

See Also

$files methods and properties

API reference based on ProcessWire core version 3.0.185

Twitter updates

  • ProcessWire 3.0.192 (dev branch) contains 11 issue fixes and 5 pull requests, over 20 commits— More
    7 January 2022
  • ProcessWire 3.0.191 core updates: updates to the installer and the profile exporter module— More
    24 December 2021
  • This week ProcessWire went on a diet, trimming the core size from 15.5 MB down to 7.5 MB by moving optional site profiles into their own GitHub repos— More
    17 December 2021

Latest news

  • ProcessWire Weekly #401
    In the 401st issue of ProcessWire Weekly we'll cover the latest core updates, check out a brand new module called Lister Native Date Format, and more. Read on!
    Weekly.pw / 15 January 2022
  • ProcessWire 3.0.190 core updates
    ProcessWire 3.0.190 has 15 commits relative to 3.0.189 and contains a mixture of issue resolutions and feature additions. This post covers them all, in addition to updates for the PageAutosave and ProFields Table modules.
    Blog / 3 December 2021
  • Subscribe to weekly ProcessWire news

“We were really happy to build our new portfolio website on ProcessWire! We wanted something that gave us plenty of control on the back-end, without any bloat on the front end - just a nice, easy to access API for all our content that left us free to design and build however we liked.” —Castus, web design agency in Sheffield, UK