getFileContent.php
Table of Contents
Functions
- getFileContent() : string
- Reads the entire contents of a file into a string.
Functions
getFileContent()
Reads the entire contents of a file into a string.
getFileContent(string|null $file[, int|null $maxBytes = null ]) : string
Symmetric counterpart of makeFile() (which writes a file): where getFileLines() reads a file line by line, this helper returns the whole content as a single string.
Parameters
- $file : string|null
-
The full path to the file to read.
- $maxBytes : int|null = null
-
Optional cap on the file size (in bytes). When set, the file is rejected before* being read if its size exceeds this value, throwing RuntimeException. Default
null(no limit). Useful as a defensive guard against OOM when the caller does not fully trust the input size.
Tags
Return values
string —The full file contents. An empty string for an empty file.