| API | Package | Subpackage | Class | Method | Reference | Last reviewed | Doc status |
|---|---|---|---|---|---|---|---|
Home |
Joomla.Framework |
FileSystem |
JFile |
read |
read() |
Never | Work in Progress |
Reads the contents of a file. If the current user has permission and safe mode is turned off, or the protocol is HTTP (i.e. the file name starts with http://) then this function will use the PHP fopen function. Otherwise, the function will use ftp (if enabled) to read the file. The function returns a string containing the contents of the file if successful. Otherwise, the function returns false and may raise a warning using the JError class.
string read ( $filename, $incpath )
| $filename | string | is a string containing the full file path. |
| $incpath | boolean | is a flag that specifies whether or not to use the include path (only applicable if the file can be opened using the PHP fopen function). |
Example: This example reads the robot.txt file.
Example
echo JFile::read( 'robots.txt' );
which might produce something like:
Result
User-agent: * Disallow: /administrator/ Disallow: /cache/ Disallow: /components/ Disallow: /editor/ Disallow: /help/ Disallow: /images/ Disallow: /includes/ Disallow: /language/ Disallow: /mambots/ Disallow: /media/ Disallow: /modules/ Disallow: /templates/ Disallow: /installation/