SplTempFileObject 类

(PHP 5 >= 5.1.2, PHP 7, PHP 8)

简介

SplTempFileObject 类为临时文件提供面向对象的接口。

类概要

class SplTempFileObject extends SplFileObject {
/* 继承的常量 */
/* 方法 */
public __construct(int $maxMemory = 2 * 1024 * 1024)
/* 继承的方法 */
public SplFileObject::fgetcsv(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): array|false
public SplFileObject::fgetss(string $allowable_tags = ?): string
public SplFileObject::flock(int $operation, int &$wouldBlock = null): bool
public SplFileObject::fputcsv(
    array $fields,
    string $separator = ",",
    string $enclosure = "\"",
    string $escape = "\\",
    string $eol = "\n"
): int|false
public SplFileObject::fscanf(string $format, mixed &...$vars): array|int|null
public SplFileObject::fseek(int $offset, int $whence = SEEK_SET): int
public SplFileObject::fwrite(string $data, int $length = 0): int|false
public SplFileObject::setCsvControl(string $separator = ",", string $enclosure = "\"", string $escape = "\\"): void
public SplFileInfo::getBasename(string $suffix = ""): string
public SplFileInfo::openFile(string $mode = "r", bool $useIncludePath = false, ?resource $context = null): SplFileObject
public SplFileInfo::setFileClass(string $class = SplFileObject::class): void
public SplFileInfo::setInfoClass(string $class = SplFileInfo::class): void
}

目录

添加备注

用户贡献笔记 1 则笔记

Steve
9 个月前
由于临时文件不是真实文件,因此某些继承的方法将无法使用。例如:

* SplFileInfo::isReadable() 和 SplFileInfo::isWritable() 返回 false,不是因为不可读或不可写,而是因为文件不存在。

* SplFileObject::flock() 失败并返回 false。

* SplFileInfo::getATime()、SplFileInfo::getCTime()、SplFileInfo::getMTime()、SplFileInfo::getOwner()、SplFileInfo::getGroup()、SplFileInfo::getInode()、SplFileInfo::getPerms() 和 SplFileInfo::getSize() 会抛出 RuntimeException "stat failed for php://temp"。但是,SplFileObject::fstat() 会成功并返回 atime = mtime = ctime = uid = gid = ino = 0 以及正确的大小。

* SplFileInfo::getType 会抛出 RuntimeException "Lstat failed for php://temp"。

* SplFileInfo::getLinkTarget 会抛出 RuntimeException "Unable to read link php://temp, error: No such file or directory"。
To Top