function PhpStreamWrapperInterface::stream_read

Same name in other branches
  1. 9 core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php \Drupal\Core\StreamWrapper\PhpStreamWrapperInterface::stream_read()
  2. 8.9.x core/lib/Drupal/Core/StreamWrapper/PhpStreamWrapperInterface.php \Drupal\Core\StreamWrapper\PhpStreamWrapperInterface::stream_read()
  3. 11.x 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

2 methods override PhpStreamWrapperInterface::stream_read()
DummyExternalReadOnlyWrapper::stream_read in core/modules/file/tests/file_test/src/StreamWrapper/DummyExternalReadOnlyWrapper.php
Read from stream.
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);

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.