本文整理汇总了PHP中Stream::size方法的典型用法代码示例。如果您正苦于以下问题:PHP Stream::size方法的具体用法?PHP Stream::size怎么用?PHP Stream::size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::size方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testTruncate
public function testTruncate()
{
$s = new Stream();
$s->open(STREAM_MODE_READWRITE);
$s->write('This is a beautiful example stream.');
// Truncating to a longer stream does not work...
$this->assertFalse($s->truncate(1000));
// ... only truncating to smaller size
$this->assertTrue($s->truncate(10));
$this->assertEquals($s->size(), 10);
$this->assertEquals($s->tell(), 10);
$this->assertEquals($s->buffer, 'This is a ');
}
示例2: testReadline
public function testReadline()
{
$stream = new Stream();
$stream->open(STREAM_MODE_WRITE);
$stream->writeLine('This is the first line.');
$stream->writeLine('This is the second line.');
$stream->writeLine('And there is a third one.');
$stream->close();
$stream->open(STREAM_MODE_READ);
$this->s = new EncapsedStream($stream, 5, $stream->size() - 35);
$this->assertEquals('is the first line.', $this->s->readLine());
$this->assertEquals('This is the second li', $this->s->readLine());
$this->assertEquals('', $this->s->readLine());
}