SplFileObject クラス

はじめに

SplFileObject クラスはファイルのためのオブジェクト指向のインターフェイスを提供します。

クラス概要

SplFileObject
extends SplFileInfo
implements RecursiveIterator SeekableIterator
/* 定数 */
public const int SplFileObject::DROP_NEW_LINE;
public const int SplFileObject::READ_AHEAD;
public const int SplFileObject::SKIP_EMPTY;
public const int SplFileObject::READ_CSV;
/* メソッド */
public SplFileObject::__construct(
    string $filename,
    string $mode = "r",
    bool $useIncludePath = false,
    resourcenull $context = null
)
public stringarrayfalse SplFileObject::current()
public bool SplFileObject::eof()
public bool SplFileObject::fflush()
public stringfalse SplFileObject::fgetc()
public arrayfalse SplFileObject::fgetcsv(string $separator = ",", string $enclosure = "\"", string $escape = "\\")
public string SplFileObject::fgets()
public string SplFileObject::fgetss(string $allowable_tags = ?)
public bool SplFileObject::flock(int $operation, int &$wouldBlock = null)
public int SplFileObject::fpassthru()
public intfalse SplFileObject::fputcsv(
    array $fields,
    string $separator = ",",
    string $enclosure = "\"",
    string $escape = "\\",
    string $eol = "\n"
)
public stringfalse SplFileObject::fread(int $length)
public arrayintnull SplFileObject::fscanf(string $format, mixed &...$vars)
public int SplFileObject::fseek(int $offset, int $whence = SEEK_SET)
public array SplFileObject::fstat()
public intfalse SplFileObject::ftell()
public bool SplFileObject::ftruncate(int $size)
public intfalse SplFileObject::fwrite(string $data, int $length = 0)
public null SplFileObject::getChildren()
public array SplFileObject::getCsvControl()
public int SplFileObject::getFlags()
public int SplFileObject::getMaxLineLen()
public false SplFileObject::hasChildren()
public int SplFileObject::key()
public void SplFileObject::next()
public void SplFileObject::rewind()
public void SplFileObject::seek(int $line)
public void SplFileObject::setCsvControl(string $separator = ",", string $enclosure = "\"", string $escape = "\\")
public void SplFileObject::setFlags(int $flags)
public void SplFileObject::setMaxLineLen(int $maxLength)
public string SplFileObject::__toString()
public bool SplFileObject::valid()
/* 継承したメソッド */
public intfalse getATime()
public string getBasename(string $suffix = "")
public intfalse getCTime()
public string getExtension()
public SplFileInfo getFileInfo(stringnull $class = null)
public string getFilename()
public intfalse getGroup()
public intfalse getInode()
public stringfalse getLinkTarget()
public intfalse getMTime()
public intfalse getOwner()
public string getPath()
public SplFileInfonull getPathInfo(stringnull $class = null)
public string getPathname()
public intfalse getPerms()
public stringfalse getRealPath()
public intfalse getSize()
public stringfalse getType()
public bool isDir()
public bool isExecutable()
public bool isFile()
public bool isLink()
public bool isReadable()
public bool isWritable()
public SplFileObject openFile(string $mode = "r", bool $useIncludePath = false, resourcenull $context = null)
public void setFileClass(string $class = SplFileObject::class)
public void setInfoClass(string $class = SplFileInfo::class)
public string __toString()

定義済み定数

SplFileObject::DROP_NEW_LINE

行末の改行を読み飛ばします。

SplFileObject::READ_AHEAD

先読み/巻き戻しで読み出します。

SplFileObject::SKIP_EMPTY

ファイルの空行を読み飛ばします。期待通りに動作させるには、READ_AHEAD フラグを有効にしないといけません。

SplFileObject::READ_CSV

CSV 列として行を読み込みます。

目次