本文整理汇总了PHP中Reader::moveCursor方法的典型用法代码示例。如果您正苦于以下问题:PHP Reader::moveCursor方法的具体用法?PHP Reader::moveCursor怎么用?PHP Reader::moveCursor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Reader
的用法示例。
在下文中一共展示了Reader::moveCursor方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testReader
public function testReader()
{
$text = <<<HTML
HELLO WORLD
HTML;
$reader = new Reader($text);
$this->assertEquals(strlen($text), strlen(trim($text)));
$this->assertEquals("HE", $reader->read(2));
$this->assertEquals(strlen($text), $reader->length());
$this->assertEquals(6, $reader->moveCursor(6)->getCursor());
$this->assertEquals('WORLD', $reader->readToEnd());
$this->assertEquals('HELLO WORLD', $reader->rewind()->readToEnd());
$this->assertEquals('HELLO ', $reader->readAndGo(6));
$this->assertEquals('WORLD', $reader->readToEnd());
# Reset position
$reader->rewind();
$this->assertNotFalse($reader->match('/(?=[a-z])/iA'));
$this->assertEquals('HELLO', $reader->match('/\\w+/A'));
$this->assertEquals(0, $reader->getCursor());
$this->assertFalse($reader->matchAndGo('/\\d+/A'));
$this->assertEquals('HELLO', $reader->matchAndGo('/\\w+/A'));
$this->assertEquals(' ', $reader->matchAndGo('/\\s+/A'));
$this->assertEquals('WORLD', $reader->matchAndGo('/\\w+/A'));
$this->assertTrue($reader->isEnd());
$reader->rewind();
$this->assertEquals('HELLO WORLD', $reader->readToEndAndGo());
$this->assertEquals(11, $reader->length());
$this->assertEquals(10, $reader->getCursor());
$this->assertTrue($reader->isEnd());
$reader = new Reader('
Hello
World
');
$reader->setCursor(strpos($reader->readAll(), 'World'));
$this->assertEquals(3, $reader->getLine());
$this->assertEquals(2, $reader->getColumn());
}