PHP Function Reference

PHP streamWrapper stream_seek() Method



The PHP streamWrapper::stream_seek() method seeks to specific location in a stream. This method is called in response to fseek(). The read/write position of the stream is updated according to the offset and whence parameters.

Syntax

public streamWrapper::stream_seek(offset, whence)

Parameters

offset Required. Specify the stream offset to seek to.
whence Required. Default is SEEK_SET. Possible values are:
  • SEEK_SET - Set position equal to offset bytes.
  • SEEK_CUR - Set position to current location plus offset.
  • SEEK_END - Set position to end-of-file plus offset.

Return Value

Return true if the position was updated, false otherwise.

Note: If not implemented, false is assumed as the return value.

Note: Upon success, streamWrapper::stream_tell() is called directly after calling streamWrapper::stream_seek(). If streamWrapper::stream_tell() fails, the return value to the caller function will be set to false.

Note: Not all seeks operations on the stream will result in this function being called. PHP streams have read buffering enabled by default (see also stream_set_read_buffer()) and seeking may be done by merely moving the buffer pointer.


❮ PHP Streams Reference