function Filesystem::readFile
Returns the content of a file as a string.
Throws
IOException If the file cannot be read
File
-
vendor/
symfony/ filesystem/ Filesystem.php, line 717
Class
- Filesystem
- Provides basic utility to manipulate the file system.
Namespace
Symfony\Component\FilesystemCode
public function readFile(string $filename) : string {
if (is_dir($filename)) {
throw new IOException(\sprintf('Failed to read file "%s": File is a directory.', $filename));
}
$content = self::box('file_get_contents', $filename);
if (false === $content) {
throw new IOException(\sprintf('Failed to read file "%s": ', $filename) . self::$lastError, 0, null, $filename);
}
return $content;
}