(PHP 5 >= 5.1.0, PHP 7, PHP 8)
SplFileObject 類為文件提供了一個面向?qū)ο蠼涌凇?
$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 方法時,從文件中讀取一行數(shù)據(jù)。
SplFileObject::SKIP_EMPTY
跳過文件中的空白行。這需要啟用
READ_AHEAD
標志,以達到預(yù)期的效果。
SplFileObject::READ_CSV以 CSV 行的形式讀取。