SplFileObject::fgets

(PHP 5 >= 5.1.0, PHP 7)

SplFileObject::fgetsGets line from file

说锟斤拷

public SplFileObject::fgets ( void ) : string

Gets a line from the file.

锟斤拷锟斤拷

锟剿猴拷锟斤拷没锟叫诧拷锟斤拷锟斤拷

锟斤拷锟斤拷值

Returns a string containing the next line from the file, or FALSE on error.

锟斤拷锟斤拷锟届常

Throws a RuntimeException if the file cannot be read.

锟斤拷锟斤拷

Example #1 SplFileObject::fgets() example

This example simply outputs the contents of file.txt line-by-line.

<?php
$file 
= new SplFileObject("file.txt");
while (!
$file->eof()) {
    echo 
$file->fgets();
}
?>

锟轿硷拷