====== read ======
{#JAPI Joomla.Framework FileSystem JFile::read #}
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 [[http://www.php.net/fopen|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 [[references:joomla.framework:utilities:JError|JError]] class.
===== Syntax =====
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 [[http://www.php.net/fopen|fopen]] function). |
===== Examples =====
Example: This example reads the robot.txt file.
echo JFile::read( 'robots.txt' );
which might produce something like:
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/
----
~~DISCUSSION~~