本文整理汇总了PHP中Stream::open方法的典型用法代码示例。如果您正苦于以下问题:PHP Stream::open方法的具体用法?PHP Stream::open怎么用?PHP Stream::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Stream
的用法示例。
在下文中一共展示了Stream::open方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_contents
public function get_contents()
{
$data = 'Test';
$f = new Stream();
$f->open(STREAM_MODE_WRITE);
$f->write($data);
$f->close();
$this->assertEquals($data, FileUtil::getContents($f));
}
示例2: archiveBytesAsStream
/**
* Returns
*
* @return io.Stream
*/
protected function archiveBytesAsStream($version = -1)
{
static $bytes = array(1 => "CCA", 2 => "CCA");
$s = new Stream();
$s->open(STREAM_WRITE);
$s->write($bytes[$version < 0 ? $this->version() : $version]);
$s->write(str_repeat("", 248));
// Reserved bytes
$s->close();
return $s;
}
示例3: __construct
/**
*
* @param string $data Initial data
* @param int $memSize Memory limit
* @param string $mode Open mode
*/
public function __construct($data = null, $memSize = null, $mode = 'w+')
{
$memSize = \intval($memSize);
$file = 'php://';
if ($memSize > 0) {
$file .= "temp/maxmemory:{$memSize}";
} else {
$file .= 'memory';
}
$stream = Stream::open($file, $mode, false);
parent::__construct($stream);
$this->write($data);
}
示例4: 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));
}
示例5: __construct
/**
*
*/
public function __construct()
{
$stream = Stream::open('php://output', 'w', false);
parent::__construct($stream);
}
示例6: __construct
/**
*
*/
public function __construct()
{
$stream = \defined('\\STDERR') ? \STDERR : Stream::open('php://stderr', 'w', false);
parent::__construct($stream);
}
示例7: __construct
/**
*
*/
public function __construct()
{
$stream = \defined('\\STDIN') ? \STDIN : Stream::open('php://stdin', 'r', false);
parent::__construct($stream);
}
示例8: __construct
/**
*
* @param string $data Initial data
* @param string $mode Open mode
*/
public function __construct($data = null, $mode = 'r+')
{
$stream = Stream::open('php://temp', $mode, false);
parent::__construct($stream);
$this->write($data);
}
示例9: positionAfterReOpen
public function positionAfterReOpen()
{
$s = new Stream();
$s->open(STREAM_MODE_WRITE);
$s->write('GIF89a');
$s->close();
$s->open(STREAM_MODE_READ);
$this->assertEquals(0, $s->tell());
$this->assertEquals('GIF89a', $s->read());
$s->close();
}
示例10: 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());
}