Stream
class Stream implements StreamInterface (View source)
The Stream class.
Constants
MODE_READ_ONLY_FROM_BEGIN |
|
MODE_READ_WRITE_FROM_BEGIN |
|
MODE_WRITE_ONLY_RESET |
|
MODE_READ_WRITE_RESET |
|
MODE_WRITE_ONLY_FROM_END |
|
MODE_READ_WRITE_FROM_END |
|
Methods
Class init.
Reads all data from the stream into a string, from the beginning to end.
Closes the stream and any underlying resources.
Separates any underlying resources from the stream.
Get the size of the stream if known.
Returns the current position of the file read/write pointer
Returns true if the stream is at the end of the stream.
Returns whether or not the stream is seekable.
Seek to a position in the stream.
Seek to the beginning of the stream.
Returns whether or not the stream is writable.
Write data to the stream.
Returns whether or not the stream is readable.
Read data from the stream.
Returns the remaining contents in a string
Get stream metadata as an associative array or retrieve a specific key.
Method to get property Resource
Details
at line line 47
__construct(string|resource $stream = 'php://memory', string $mode = 'r')
Class init.
at line line 66
string
__toString()
Reads all data from the stream into a string, from the beginning to end.
This method MUST attempt to seek to the beginning of the stream before reading data and read the stream until the end is reached.
Warning: This could attempt to load a large amount of data into memory.
This method MUST NOT raise an exception in order to conform with PHP's string casting operations.
at line line 90
void
close()
Closes the stream and any underlying resources.
at line line 110
Stream
attach(string|resource $stream, string $mode = 'r')
Method to attach resource into object.
at line line 137
resource|null
detach()
Separates any underlying resources from the stream.
After the stream has been detached, the stream is in an unusable state.
at line line 152
int|null
getSize()
Get the size of the stream if known.
at line line 170
int
tell()
Returns the current position of the file read/write pointer
at line line 192
bool
eof()
Returns true if the stream is at the end of the stream.
at line line 207
bool
isSeekable()
Returns whether or not the stream is seekable.
at line line 235
boolean
seek(int $offset, int $whence = SEEK_SET)
Seek to a position in the stream.
at line line 267
rewind()
Seek to the beginning of the stream.
If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).
at line line 277
bool
isWritable()
Returns whether or not the stream is writable.
at line line 297
int
write(string $string)
Write data to the stream.
at line line 319
bool
isReadable()
Returns whether or not the stream is readable.
at line line 343
string
read(int $length)
Read data from the stream.
at line line 372
string
getContents()
Returns the remaining contents in a string
at line line 403
array|mixed|null
getMetadata(string $key = null)
Get stream metadata as an associative array or retrieve a specific key.
The keys returned are identical to the keys returned from PHP's streamgetmeta_data() function.
at line line 425
resource
getResource()
Method to get property Resource