Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. SplFileInfo.php

function SplFileInfo::getContents

Returns the contents of the file.

Throws

\RuntimeException

Overrides SplFileInfo::getContents

1 method overrides SplFileInfo::getContents()
SplFileInfo::getContents in vendor/symfony/finder/SplFileInfo.php
Returns the contents of the file.

File

vendor/symfony/finder/SplFileInfo.php, line 66

Class

SplFileInfo
Extends \SplFileInfo to support relative paths.

Namespace

Symfony\Component\Finder

Code

public function getContents() : string {
    set_error_handler(function ($type, $msg) use (&$error) {
        $error = $msg;
    });
    try {
        $content = file_get_contents($this->getPathname());
    } finally {
        restore_error_handler();
    }
    if (false === $content) {
        throw new \RuntimeException($error);
    }
    return $content;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal