Since: 1.7.0

class BufferStreamHandler

Generic Buffer stream handler

This class provides a generic buffer stream. It can be used to store/retrieve/manipulate string buffers with the standard PHP filesystem I/O methods.

Properties

int Since: 1.7.0
$position

Stream position

string Since: 1.7.0
$name

Buffer name

array Since: 3.0.0
$buffers

Buffer hash

Methods

static void
stream_register()

Function to register the stream wrapper

bool
stream_open(string $path, string $mode, int $options, string $openedPath)

Function to open file or url

mixed
stream_read(int $count)

Read stream

int
stream_write(string $data)

Write stream

int
stream_tell()

Function to get the current position of the stream

bool
stream_eof()

Function to test for end of file pointer

bool
stream_seek(int $offset, int $whence)

The read write position updates in response to $offset and $whence

bool
seek_set(int $offset)

Set the position to the offset

bool
seek_cur(int $offset)

Adds the offset to current position

bool
seek_end(int $offset)

Sets the position to the end of the current buffer + offset

Details

static void stream_register()

Since: 3.8.2

Function to register the stream wrapper

Return Value

void

bool stream_open(string $path, string $mode, int $options, string $openedPath)

Since: 1.7.0

Function to open file or url

Parameters

string $path

The URL that was passed

string $mode

Mode used to open the file fopen

int $options

Flags used by the API, may be STREAM_USE_PATH and STREAM_REPORT_ERRORS

string $openedPath

Full path of the resource. Used with STREAM_USE_PATH option

Return Value

bool

See also

streamWrapper::stream_open

mixed stream_read(int $count)

Since: 1.7.0

Read stream

Parameters

int $count

How many bytes of data from the current position should be returned.

Return Value

mixed

The data from the stream up to the specified number of bytes (all data if the total number of bytes in the stream is less than $count. Null if the stream is empty.

See also

streamWrapper::stream_read

int stream_write(string $data)

Since: 1.7.0

Write stream

Parameters

string $data

The data to write to the stream.

Return Value

int

See also

streamWrapper::stream_write

int stream_tell()

Since: 1.7.0

Function to get the current position of the stream

Return Value

int

See also

streamWrapper::stream_tell

bool stream_eof()

Since: 1.7.0

Function to test for end of file pointer

Return Value

bool

True if the pointer is at the end of the stream

See also

streamWrapper::stream_eof

bool stream_seek(int $offset, int $whence)

Since: 1.7.0

The read write position updates in response to $offset and $whence

Parameters

int $offset

The offset in bytes

int $whence

Position the offset is added to Options are SEEK_SET, SEEK_CUR, and SEEK_END

Return Value

bool

True if updated

See also

streamWrapper::stream_seek

protected bool seek_set(int $offset)

Set the position to the offset

Parameters

int $offset

The offset in bytes

Return Value

bool

protected bool seek_cur(int $offset)

Adds the offset to current position

Parameters

int $offset

The offset in bytes

Return Value

bool

protected bool seek_end(int $offset)

Sets the position to the end of the current buffer + offset

Parameters

int $offset

The offset in bytes

Return Value

bool