SplFileObject::fgets

Gets line from file

&reftitle.description; public `string` `SplFileObject::fgets`

Gets a line from the file.

&reftitle.parameters; &no.function.parameters;
&reftitle.returnvalues;

Returns a string containing the next line from the file, or &false; on error.

&reftitle.errors;

Throws a `RuntimeException` if the file cannot be read.

&reftitle.examples;

### `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();
    }
    ?>

&reftitle.seealso;

- `fgets`
- `SplFileObject::fgetss`
- `SplFileObject::fgetc`
- `SplFileObject::current`