Php/docs/class.splfileobject
(PHP 5 >= 5.1.0, PHP 7)
简介
SplFileObject类为文件提供了一个面向对象接口.
类摘要
SplFileObject extends SplFileInfo implements RecursiveIterator , SeekableIterator {
const
integer
DROP_NEW_LINE
= 1
const
integer
READ_AHEAD
= 2
const
integer
SKIP_EMPTY
= 4
const
integer
READ_CSV
= 8
/* 方法 */
public current ( ) : string|array
public eof ( ) : bool
public fflush ( ) : bool
public fgetc ( ) : string
public fgetcsv
([ string $delimiter
= ","
[, string $enclosure
= "\""
[, string $escape
= "\\"
]]] ) : array
public fgets ( ) : string
public fgetss
([ string $allowable_tags
] ) : string
public flock
( int $operation
[, int &$wouldblock
] ) : bool
public fpassthru ( ) : int
public fputcsv
( array $fields
[, string $delimiter
= ","
[, string $enclosure
= '"'
[, string $escape
= "\\"
]]] ) : int|false
public fread
( int $length
) : string|false
public fseek
( int $offset
[, int $whence
= SEEK_SET
] ) : int
public fstat ( ) : array
public ftell ( ) : int
public ftruncate
( int $size
) : bool
public fwrite
( string $str
[, int $length
] ) : int
public getChildren ( ) : void
public getCsvControl ( ) : array
public getFlags ( ) : int
public getMaxLineLen ( ) : int
public hasChildren ( ) : bool
public key ( ) : int
public next ( ) : void
public rewind ( ) : 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 ( ) : bool
/* 继承的方法 */
public SplFileInfo::getATime ( ) : int
public SplFileInfo::getBasename
([ string $suffix
] ) : string
public SplFileInfo::getCTime ( ) : int
public SplFileInfo::getExtension ( ) : string
public SplFileInfo::getFileInfo
([ string $class_name
] ) : SplFileInfo
public SplFileInfo::getFilename ( ) : string
public SplFileInfo::getGroup ( ) : int
public SplFileInfo::getInode ( ) : int
public SplFileInfo::getLinkTarget ( ) : string
public SplFileInfo::getMTime ( ) : int
public SplFileInfo::getOwner ( ) : int
public SplFileInfo::getPath ( ) : string
public SplFileInfo::getPathInfo
([ string $class_name
] ) : SplFileInfo
public SplFileInfo::getPathname ( ) : string
public SplFileInfo::getPerms ( ) : int
public SplFileInfo::getRealPath ( ) : string
public SplFileInfo::getSize ( ) : int
public SplFileInfo::getType ( ) : string
public SplFileInfo::isDir ( ) : bool
public SplFileInfo::isExecutable ( ) : bool
public SplFileInfo::isFile ( ) : bool
public SplFileInfo::isLink ( ) : bool
public SplFileInfo::isReadable ( ) : bool
public SplFileInfo::isWritable ( ) : 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 ( ) : string
}
预定义常量
SplFileObject::DROP_NEW_LINE
- Drop newlines at the end of a line.
SplFileObject::READ_AHEAD
- Read on rewind/next.
SplFileObject::SKIP_EMPTY
- Skips empty lines in the file. This requires the
READ_AHEAD
flag be enabled, to work as expected. SplFileObject::READ_CSV
- Read lines as CSV rows.
更新日志
版本 | 说明 |
---|---|
5.3.9 | SplFileObject::SKIP_EMPTY value changed to 4.
Previously, value was 6. |
Table of Contents
- SplFileObject::__construct — Construct a new file object
- SplFileObject::current — Retrieve current line of file
- SplFileObject::eof — Reached end of file
- SplFileObject::fflush — Flushes the output to the file
- SplFileObject::fgetc — Gets character from file
- SplFileObject::fgetcsv — Gets line from file and parse as CSV fields
- SplFileObject::fgets — Gets line from file
- SplFileObject::fgetss — Gets line from file and strip HTML tags
- SplFileObject::flock — Portable file locking
- SplFileObject::fpassthru — Output all remaining data on a file pointer
- SplFileObject::fputcsv — Write a field array as a CSV line
- SplFileObject::fread — Read from file
- SplFileObject::fscanf — Parses input from file according to a format
- SplFileObject::fseek — Seek to a position
- SplFileObject::fstat — Gets information about the file
- SplFileObject::ftell — Return current file position
- SplFileObject::ftruncate — Truncates the file to a given length
- SplFileObject::fwrite — Write to file
- SplFileObject::getChildren — No purpose
- SplFileObject::getCsvControl — Get the delimiter, enclosure and escape character for CSV
- SplFileObject::getCurrentLine — Alias of SplFileObject::fgets
- SplFileObject::getFlags — Gets flags for the SplFileObject
- SplFileObject::getMaxLineLen — Get maximum line length
- SplFileObject::hasChildren — SplFileObject does not have children
- SplFileObject::key — Get line number
- SplFileObject::next — Read next line
- SplFileObject::rewind — Rewind the file to the first line
- SplFileObject::seek — Seek to specified line
- SplFileObject::setCsvControl — Set the delimiter, enclosure and escape character for CSV
- SplFileObject::setFlags — Sets flags for the SplFileObject
- SplFileObject::setMaxLineLen — Set maximum line length
- SplFileObject::__toString — Alias of SplFileObject::fgets
- SplFileObject::valid — Not at EOF
/* 常量 */