PHP Velho Oeste 2024

The SplTempFileObject class

(PHP 5 >= 5.1.2, PHP 7)

Introducere

The SplTempFileObject class offers an object oriented interface for a temporary file.

Sinopsisul clasei

SplTempFileObject extends SplFileObject implements SeekableIterator , RecursiveIterator {
/* Constante moștenite */
const int SplFileObject::READ_AHEAD = 2 ;
const int SplFileObject::SKIP_EMPTY = 4 ;
const int SplFileObject::READ_CSV = 8 ;
/* Metode */
public __construct ( int $max_memory = ? )
/* Metode moștenite */
public SplFileObject::current ( ) : string|array
public SplFileObject::eof ( ) : bool
public SplFileObject::fflush ( ) : bool
public SplFileObject::fgetc ( ) : string
public SplFileObject::fgetcsv ( string $delimiter = "," , string $enclosure = "\"" , string $escape = "\\" ) : array
public SplFileObject::fgets ( ) : string
public SplFileObject::fgetss ( string $allowable_tags = ? ) : string
public SplFileObject::flock ( int $operation , int &$wouldblock = ? ) : bool
public SplFileObject::fpassthru ( ) : int
public SplFileObject::fputcsv ( array $fields , string $delimiter = "," , string $enclosure = '"' , string $escape = "\\" ) : int|false
public SplFileObject::fread ( int $length ) : string|false
public SplFileObject::fscanf ( string $format , mixed &...$vars ) : mixed
public SplFileObject::fseek ( int $offset , int $whence = SEEK_SET ) : int
public SplFileObject::fstat ( ) : array
public SplFileObject::ftell ( ) : int
public SplFileObject::ftruncate ( int $size ) : bool
public SplFileObject::fwrite ( string $str , int $length = ? ) : int
public SplFileObject::getChildren ( ) : void
public SplFileObject::getCsvControl ( ) : array
public SplFileObject::getFlags ( ) : int
public SplFileObject::hasChildren ( ) : bool
public SplFileObject::key ( ) : int
public SplFileObject::next ( ) : void
public SplFileObject::rewind ( ) : void
public SplFileObject::seek ( int $line_pos ) : void
public SplFileObject::setCsvControl ( string $delimiter = "," , string $enclosure = "\"" , string $escape = "\\" ) : void
public SplFileObject::setFlags ( int $flags ) : void
public SplFileObject::setMaxLineLen ( int $max_len ) : void
public SplFileObject::valid ( ) : bool
}

Cuprins

add a note add a note

User Contributed Notes 1 note

up
0
Steve
6 months ago
Since a temporary file is not a real file, some inherited methods will not work. For example,

* SplFileInfo::isReadable() and SplFileInfo::isWritable() return false, not because it was unreadable or unwritable, but because the file does not exists.

* SplFileObject::flock() fails and returns false.

* SplFileInfo::getATime(), SplFileInfo::getCTime(), SplFileInfo::getMTime(), SplFileInfo::getOwner(), SplFileInfo::getGroup(), SplFileInfo::getInode(), SplFileInfo::getPerms(), and SplFileInfo::getSize() throw RuntimeException "stat failed for php://temp". However, SplFileObject::fstat() succeeds and returns atime = mtime = ctime = uid = gid = ino = 0 together with the correct size.

* SplFileInfo::getType throws RuntimeException "Lstat failed for php://temp".

* SplFileInfo::getLinkTarget throws RuntimeException "Unable to read link php://temp, error: No such file or directory".
To Top