CFile::getContents PHP Method

getContents() public method

Reads data from filesystem object if it is a regular file. List files and directories inside the specified path if filesystem object is a directory.
public getContents ( boolean $recursive = False, string $filter = null ) : string | array | boolean
$recursive boolean If True method would return all directory descendants.
$filter string Filter to be applied to all directory descendants. Could be a string, or an array of strings (perl regexp are supported, if started with '~').
return string | array | boolean Data read for files, or directory contents names array. False on fail.
    public function getContents($recursive = False, $filter = null)
    {
        if ($this->getReadable()) {
            if ($this->getIsFile()) {
                if ($contents = file_get_contents($this->_realpath)) {
                    return $contents;
                }
            } else {
                return $this->dirContents($this->_realpath, $recursive, $filter);
            }
        }
        $this->addLog('Unable to get filesystem object contents' . ($filter !== null ? ' *using supplied filter*' : ''));
        return False;
    }