本文整理汇总了PHP中Stream::rewind方法的典型用法代码示例。如果您正苦于以下问题:PHP Stream::rewind方法的具体用法?PHP Stream::rewind怎么用?PHP Stream::rewind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::rewind方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRead
public function testRead()
{
$s = new Stream();
$s->open(STREAM_MODE_READWRITE);
$s->writeLine('Pellentesque sapien enim, pellentesque sed.');
$s->writeLine('Sed et tortor suscipit velit.');
$s->writeLine('Phasellus at metus quis erat.');
$this->assertEquals($s->read(), '');
$this->assertEquals($s->tell(), 104);
// Rewind and read each line
$s->rewind();
$this->assertEquals($s->readLine(), 'Pellentesque sapien enim, pellentesque sed.');
$this->assertEquals($s->readLine(), 'Sed et tortor suscipit velit.');
$this->assertEquals($s->readLine(), 'Phasellus at metus quis erat.');
// No more lines left, we should receive an empty string
$this->assertEquals($s->readLine(), '');
// Check that the offset is still at the "end" of the stream
$this->assertEquals($s->tell(), 104);
}
示例2: getThumbnail
/**
* Get Thumbnail
*
* @return img.Image
*/
public function getThumbnail()
{
$s = new Stream();
$s->open(STREAM_MODE_WRITE);
$s->write(exif_thumbnail($this->getFilename()));
$s->rewind();
return Image::loadFrom(new StreamReader($s));
}