本文整理匯總了PHP中Stream::seek方法的典型用法代碼示例。如果您正苦於以下問題:PHP Stream::seek方法的具體用法?PHP Stream::seek怎麽用?PHP Stream::seek使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Stream
的用法示例。
在下文中一共展示了Stream::seek方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: seek
public function seek($offset, $whence = SEEK_SET)
{
parent::seek($offset, $whence);
if (fseek($this->stream, $offset, $whence) === -1) {
throw new \Exception(sprintf('Unable to seek to stream position %d with whence %s', $offset, var_export($whence, true)));
}
}
示例2: testThrowWhenPositionNotSeekable
/**
* @expectedException Innmind\Filesystem\Exception\PositionNotSeekableException
*/
public function testThrowWhenPositionNotSeekable()
{
$resource = fopen('php://temp', 'r+');
fwrite($resource, 'Lorem ipsum dolor');
$stream = new Stream($resource);
$stream->seek(200);
}
示例3: testOverwrite
public function testOverwrite()
{
$s = new Stream();
$s->open(STREAM_MODE_READWRITE);
$s->writeLine('Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Curabitur aliquam.');
$s->seek(20);
$s->writeLine('Lorem ipsum dolor sit amet.');
$this->assertEquals($s->buffer, "Lorem ipsum dolor siLorem ipsum dolor sit amet.\ning elit. Curabitur aliquam.\n");
}