Describes a data stream.
Typically, an instance will wrap a PHP stream; this interface provides a wrapper around the most common operations, including serialization of the entire stream to a string.
Table of Contents MethodsReads all data from the stream into a string, from the beginning to end.
public __toString() : string
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.
TagsCloses the stream and any underlying resources.
public close() : void
detach()
Separates any underlying resources from the stream.
public detach() : resource|null
After the stream has been detached, the stream is in an unusable state.
Return valuesresource|null —Underlying PHP stream, if any
eof()Returns true if the stream is at the end of the stream.
public eof() : bool
Return valuesbool getContents()
Returns the remaining contents in a string
public getContents() : string
Tags
if unable to read or an error occurs while reading.
Get stream metadata as an associative array or retrieve a specific key.
public getMetadata([string|null $key = null ]) : array<string|int, mixed>|mixed|null
The keys returned are identical to the keys returned from PHP's stream_get_meta_data() function.
ParametersSpecific metadata to retrieve.
Returns an associative array if no key is provided. Returns a specific key value if a key is provided and the value is found, or null if the key is not found.
getSize()Get the size of the stream if known.
public getSize() : int|null
Return valuesint|null —
Returns the size in bytes if known, or null if unknown.
isReadable()Returns whether or not the stream is readable.
public isReadable() : bool
Return valuesbool isSeekable()
Returns whether or not the stream is seekable.
public isSeekable() : bool
Return valuesbool isWritable()
Returns whether or not the stream is writable.
public isWritable() : bool
Return valuesbool read()
Read data from the stream.
public read(int $length) : string
Parameters
Read up to $length bytes from the object and return them. Fewer than $length bytes may be returned if underlying stream call returns fewer bytes.
if an error occurs.
Returns the data read from the stream, or an empty string if no bytes are available.
rewind()Seek to the beginning of the stream.
public rewind() : void
If the stream is not seekable, this method will raise an exception; otherwise, it will perform a seek(0).
Tagson failure.
Seek to a position in the stream.
public seek(int $offset[, int $whence = SEEK_SET ]) : void
Parameters
Stream offset
Specifies how the cursor position will be calculated based on the seek offset. Valid values are identical to the built-in PHP $whence values for fseek()
. SEEK_SET: Set position equal to offset bytes SEEK_CUR: Set position to current location plus offset SEEK_END: Set position to end-of-stream plus offset.
on failure.
Returns the current position of the file read/write pointer
public tell() : int
Tags
on error.
Position of the file pointer
write()Write data to the stream.
public write(string $string) : int
Parameters
The string that is to be written.
on failure.
Returns the number of bytes written to the stream.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4