Create a new stream based on the input type.
Options is an associative array that can contain the following keys: - metadata: Array of custom metadata. - size: Size of the stream.
This method accepts the following
Psr\Http\Message\StreamInterface: Returns the value as-is.
string: Creates a stream object that uses the given string as the contents.
resource: Creates a stream object that wraps the given PHP stream resource.
Iterator: If the provided value implements
Iterator, then a read-only stream object will be created that wraps the given iterable. Each time the stream is read from, data from the iterator will fill a buffer and will be continuously called until the buffer is equal to the requested read size. Subsequent read calls will first read from the buffer and then call
next on the underlying iterator until it is exhausted.
__toString(): If the object has the
__toString() method, the object will be cast to a string and then a stream will be returned that uses the string value.
null is passed, an empty stream object is returned.
callable When a callable is passed, a read-only stream object will be created that invokes the given callable. The callable is invoked with the number of suggested bytes to read. The callable can return any number of bytes, but MUST return
false when there is no more data to return. The stream object that wraps the callable will invoke the callable until the number of requested bytes are available. Any additional bytes will be buffered and used in subsequent reads.
Deprecated: stream_for will be removed in guzzlehttp/psr7:2.0. Use Utils::streamFor instead.
Located at functions.php
||Entity body data|
Return value summary
Thrown exceptions summary
||if the $resource arg is not valid.|