La classe SplFileObject

(PHP 5 >= 5.1.0, PHP 7)

Introduction

La classe SplFileObject offre une interface orientée objet pour un fichier.

Synopsis de la classe

SplFileObject extends SplFileInfo implements RecursiveIterator , SeekableIterator {
/* Constantes */
const integer DROP_NEW_LINE = 1 ;
const integer READ_AHEAD = 2 ;
const integer SKIP_EMPTY = 4 ;
const integer READ_CSV = 8 ;
/* Méthodes */
public __construct ( string $filename [, string $open_mode = "r" [, bool $use_include_path = false [, resource $context ]]] )
public current ( void ) : string|array
public eof ( void ) : bool
public fflush ( void ) : bool
public fgetc ( void ) : string
public fgetcsv ([ string $delimiter = "," [, string $enclosure = "\"" [, string $escape = "\\" ]]] ) : array
public fgets ( void ) : string
public fgetss ([ string $allowable_tags ] ) : string
public flock ( int $operation [, int &$wouldblock ] ) : bool
public fpassthru ( void ) : int
public fputcsv ( array $fields [, string $delimiter = "," [, string $enclosure = '"' [, string $escape = "\\" ]]] ) : int
public fread ( int $length ) : string
public fscanf ( string $format [, mixed &$... ] ) : mixed
public fseek ( int $offset [, int $whence = SEEK_SET ] ) : int
public fstat ( void ) : array
public ftell ( void ) : int
public ftruncate ( int $size ) : bool
public fwrite ( string $str [, int $length ] ) : int
public getChildren ( void ) : void
public getCsvControl ( void ) : array
public getFlags ( void ) : int
public getMaxLineLen ( void ) : int
public hasChildren ( void ) : bool
public key ( void ) : int
public next ( void ) : void
public rewind ( void ) : void
public seek ( int $line_pos ) : void
public setCsvControl ([ string $delimiter = "," [, string $enclosure = "\"" [, string $escape = "\\" ]]] ) : void
public setFlags ( int $flags ) : void
public setMaxLineLen ( int $max_len ) : void
public valid ( void ) : bool
/* Méthodes héritées */
public SplFileInfo::getATime ( void ) : int
public SplFileInfo::getBasename ([ string $suffix ] ) : string
public SplFileInfo::getCTime ( void ) : int
public SplFileInfo::getExtension ( void ) : string
public SplFileInfo::getFileInfo ([ string $class_name ] ) : SplFileInfo
public SplFileInfo::getFilename ( void ) : string
public SplFileInfo::getGroup ( void ) : int
public SplFileInfo::getInode ( void ) : int
public SplFileInfo::getLinkTarget ( void ) : string
public SplFileInfo::getMTime ( void ) : int
public SplFileInfo::getOwner ( void ) : int
public SplFileInfo::getPath ( void ) : string
public SplFileInfo::getPathInfo ([ string $class_name ] ) : SplFileInfo
public SplFileInfo::getPathname ( void ) : string
public SplFileInfo::getPerms ( void ) : int
public SplFileInfo::getRealPath ( void ) : string
public SplFileInfo::getSize ( void ) : int
public SplFileInfo::getType ( void ) : string
public SplFileInfo::isDir ( void ) : bool
public SplFileInfo::isExecutable ( void ) : bool
public SplFileInfo::isFile ( void ) : bool
public SplFileInfo::isLink ( void ) : bool
public SplFileInfo::isReadable ( void ) : bool
public SplFileInfo::isWritable ( void ) : bool
public SplFileInfo::openFile ([ string $open_mode = "r" [, bool $use_include_path = FALSE [, resource $context = NULL ]]] ) : SplFileObject
public SplFileInfo::setFileClass ([ string $class_name = "SplFileObject" ] ) : void
public SplFileInfo::setInfoClass ([ string $class_name = "SplFileInfo" ] ) : void
public SplFileInfo::__toString ( void ) : string
}

Constantes pré-définies

SplFileObject::DROP_NEW_LINE

Supprime les nouvelles lignes à la fin d'une ligne.

SplFileObject::READ_AHEAD

Lecture sur rewind/next.

SplFileObject::SKIP_EMPTY

Ignore les lignes vierges du fichier. Ceci nécessite l'activation du drapeau READ_AHEAD afin de fonctionner comme attendu.

SplFileObject::READ_CSV

Lit les lignes en tant que lignes CSV.

Historique

Version Description
5.3.9 La valeur de SplFileObject::SKIP_EMPTY est maintenant de 4. Précédemment, la valeur était de 6.

Sommaire