peek() public method

Extracts a string corresponding to mb_substr(@mlink{$rest}, 0, $len), without advancing the scan pointer.
public peek ( $len ) : string
$len
return string
Esempio n. 1
0
 function testPeek()
 {
     $sc = new StringScanner("foobarbaz");
     $this->assertEqual($sc->peek(4), "foob");
     $this->assertEqual($sc->peek(0), "");
     $this->assertEqual($sc->peek(9), "foobarbaz");
     $this->assertEqual($sc->peek(10), "foobarbaz");
     $this->assertEqual($sc->peek(5), "fooba");
     $sc->pos = 3;
     $this->assertEqual($sc->peek(3), "bar");
     $this->assertEqual($sc->peek(9), "barbaz");
     $this->assertEqual($sc->peek(5), "barba");
     $sc->pos = 9;
     $this->assertEqual($sc->peek(3), "");
 }
Esempio n. 2
0
 public function testPeek()
 {
     $s = new StringScanner('test string');
     $this->assertEquals("test st", $s->peek(7));
     $this->assertEquals("test st", $s->peek(7));
 }