public function Stream::seek in Zircon Profile 8
Same name in this branch
- 8 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::seek()
- 8 vendor/guzzlehttp/psr7/src/Stream.php \GuzzleHttp\Psr7\Stream::seek()
- 8 vendor/symfony/psr-http-message-bridge/Tests/Fixtures/Stream.php \Symfony\Bridge\PsrHttpMessage\Tests\Fixtures\Stream::seek()
Same name and namespace in other branches
- 8.0 vendor/zendframework/zend-diactoros/src/Stream.php \Zend\Diactoros\Stream::seek()
Seek to a position in the stream.
@link http://www.php.net/manual/en/function.fseek.php
Parameters
int $offset Stream offset:
int $whence 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.
Throws
\RuntimeException on failure.
Overrides StreamInterface::seek
1 call to Stream::seek()
- Stream::rewind in vendor/
zendframework/ zend-diactoros/ src/ Stream.php - Seek to the beginning of the stream.
File
- vendor/
zendframework/ zend-diactoros/ src/ Stream.php, line 153
Class
- Stream
- Implementation of PSR HTTP streams
Namespace
Zend\DiactorosCode
public function seek($offset, $whence = SEEK_SET) {
if (!$this->resource) {
throw new RuntimeException('No resource available; cannot seek position');
}
if (!$this
->isSeekable()) {
throw new RuntimeException('Stream is not seekable');
}
$result = fseek($this->resource, $offset, $whence);
if (0 !== $result) {
throw new RuntimeException('Error seeking within stream');
}
return true;
}