JFile/read
Aus Joomla! Dokumentation
< JFile(Weitergeleitet von Joomla! Programmierung/Framework/JFile/read)
JFile/read liest den Inhalt einer Datei.
Inhaltsverzeichnis |
[Bearbeiten] Syntax
static read( $filename, [$incpath], [$amount], [$chunksize], [$offset] )
| Parameter | Datentyp | Beschreibung | Standardwert |
|---|---|---|---|
| $filename | string | Der komplette Pfad zur Datei | --- |
| [$incpath] | boolean | Soll der Include Path genutzt werden ? | false |
| [$amount] | integer | Die Menge die von der Datei gelesen werden soll | 0 |
| [$chunksize] | integer | Die Grösse der Stücke (chunks) | 8192 |
| [$offset] | integer | Der Versatz (offset) | 0 |
[Bearbeiten] Beispiel
$fileName = 'pfad'.DS.'zur'.DS.'datei.txt'; if( ! $buffer = JFile::read($fileName) ) { echo 'Die Datei konnte nicht gelesen werden'; return false; } echo $buffer;
[Bearbeiten] Siehe auch
- JFile->read() auf api.joomla.org
[Bearbeiten] Quellcode
public static function read($filename, $incpath = false, $amount = 0, $chunksize = 8192, $offset = 0) { // Initialise variables. $data = null; if ($amount && $chunksize > $amount) { $chunksize = $amount; } { return false; } if ($offset) { } { if ($amount && $fsize > $amount) { } else { } } else { $data = ''; // While it's: // 1: Not the end of the file AND // 2a: No Max Amount set OR // 2b: The length of the data is less than the max amount we want { } } return $data; }