src/Service/Misc/File.php
public function getFileContents($filePath, $showError = true)
    {
        $filePath = realpath($filePath);

        if ($this->fileIsReadable($filePath) === false) {
            if ($showError === true) {
                // This file was not readable! We need to tell the user!
                $this->pool->messages->addMessage('fileserviceAccess', array($this->filterFilePath($filePath)));
            }
            // Return empty string.
            return '';
        }

        // Is it readable and does it have any content?
        $size = filesize($filePath);
        if ($size > 0) {
            $file = fopen($filePath, 'r');
            $result = fread($file, $size);
            fclose($file);
            return $result;
        }

        // Empty file returns an empty string.
        return '';
    }
public function getFileContents($filePath, $showError = true)
    {
        $filePath = realpath($filePath);

        if ($this->fileIsReadable($filePath) === false) {
            if ($showError === true) {
                // This file was not readable! We need to tell the user!
                $this->pool->messages->addMessage('fileserviceAccess', array($this->filterFilePath($filePath)));
            }
            // Return empty string.
            return '';
        }

        // Is it readable and does it have any content?
        $size = filesize($filePath);
        if ($size > 0) {
            $file = fopen($filePath, 'r');
            $result = fread($file, $size);
            fclose($file);
            return $result;
        }

        // Empty file returns an empty string.
        return '';
    }
public function getFileContents ( $ filePath , $ showError = true ) { $ filePath = realpath ( $ filePath ) ; if ( $ this -> fileIsReadable ( $ filePath ) === false ) { if ( $ showError === true ) { // This file was not readable! We need to tell the user! $ this -> pool -> messages -> addMessage ( 'fileserviceAccess' , array ( $ this -> filterFilePath ( $ filePath ) ) ) ; } // Return empty string. return '' ; } // Is it readable and does it have any content? $ size = filesize ( $ filePath ) ; if ( $ size > 0 ) { $ file = fopen ( $ filePath , 'r' ) ; $ result = fread ( $ file , $ size ) ; fclose ( $ file ) ; return $ result ; } // Empty file returns an empty string. return '' ; }
Reads the content of a file.

@param string $filePath
The path to the file.
@param boolean $showError
Do we need to display na error message?

@return string
The content of the file, if readable.
Reads the content of a file .