Skip to content

Stream: eof Example

Terry L edited this page Jun 20, 2020 · 2 revisions
Clone this wiki locally

Shieldon\Psr7\Stream

eof()

Returns true if the stream is at the end of the stream.

  • return bool
$resource = fopen(BOOTSTRAP_DIR . '/sample/shieldon_logo.png', 'r+');
$stream = new Stream($resource);

$stream->seek(10);

if ($stream->eof()) {
    echo 'The position of the file pointer of the stream is at the end.';
} else {
    echo 'Not at the end.';
}
// Outputs: Not at the end.

$stream->seek(15166);

if ($stream->eof()) {
    echo 'The position of the file pointer of the stream is at the end.';
} else {
    echo 'Not at the end.';
}
// Outputs: The position of the file pointer of the stream is at the end.