(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject 类为文件提供了一个面向对象接口。
$filename
,$mode
= "r",$useIncludePath
= false
,$context
= null
$separator
= ",", string $enclosure
= "\"", string $escape
= "\\"): array|false$fields
,$separator
= ",",$enclosure
= "\"",$escape
= "\\",$eol
= "\n"$separator
= ",", string $enclosure
= "\"", string $escape
= "\\"): void$mode
= "r", bool $useIncludePath
= false
, ?resource $context
= null
): SplFileObjectSplFileObject::DROP_NEW_LINE
删除行尾的换行符。
SplFileObject::READ_AHEAD
使用 rewind 或 next 方法时,从文件中读取一行数据。
SplFileObject::SKIP_EMPTY
跳过文件中的空白行。这需要启用
READ_AHEAD
标志,以达到预期的效果。
SplFileObject::READ_CSV
以 CSV 行的形式读取。