You are here

public function PhpStreamWrapperInterface::stream_read in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php \Drupal\Core\StreamWrapper\PhpStreamWrapperInterface::stream_read()

Read from stream.

This method is called in response to fread() and fgets().

Note, remember to update the read/write position of the stream (by the number of bytes that were successfully read).

Note, PhpStreamWrapperInterface::stream_eof() is called directly after calling PhpStreamWrapperInterface::stream_read() to check if EOF has been reached. If not implemented, EOF is assumed.

Warning, when reading the whole file (e.g., with file_get_contents()), PHP will call PhpStreamWrapperInterface::stream_read() followed by PhpStreamWrapperInterface::stream_eof() in a loop but as long as PhpStreamWrapperInterface::stream_read() returns a non-empty string, the return value of PhpStreamWrapperInterface::stream_eof() is ignored.

Parameters

int $count: How many bytes of data from the current position should be returned.

Return value

string|false If there are less than $count bytes available, return as many as are available. If no more data is available, return either FALSE or an empty string.

See also

fread()

fgets()

http://php.net/manual/en/streamwrapper.stream-read.php

1 method overrides PhpStreamWrapperInterface::stream_read()
LocalStream::stream_read in core/lib/Drupal/Core/StreamWrapper/LocalStream.php
Read from stream.

File

core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php, line 350

Class

PhpStreamWrapperInterface
Defines a generic PHP stream wrapper interface.

Namespace

Drupal\Core\StreamWrapper

Code

public function stream_read($count);