read() public method

Reads data from the stream resource
public read ( integer $length = null, integer $offset = null ) : string
$length integer If specified, will read up to $length bytes from the stream. If no value is specified, all remaining bytes in the buffer will be read.
$offset integer Seek to the specified byte offset before reading.
return string Returns string read from stream resource on success, false otherwise.
コード例 #1
0
ファイル: StreamTest.php プロジェクト: WarToaster/HangOn
 public function testWriteAndRead()
 {
     $stream = new Stream($this->_testConfig);
     $this->assertTrue(is_resource($stream->open()));
     $this->assertTrue(is_resource($stream->resource()));
     $result = $stream->write();
     $this->assertEqual(83, $result);
     $this->assertPattern("/^HTTP/", (string) $stream->read());
 }
コード例 #2
0
ファイル: StreamTest.php プロジェクト: unionofrad/lithium
 public function testWriteAndRead()
 {
     $stream = new Stream($this->_testConfig);
     $this->assertInternalType('resource', $stream->open());
     $this->assertInternalType('resource', $stream->resource());
     $result = $stream->write();
     $this->assertEqual(84, $result);
     $this->assertPattern("/^HTTP/", (string) $stream->read());
 }
コード例 #3
0
ファイル: StreamTest.php プロジェクト: EHER/chegamos
 public function testWriteAndRead()
 {
     $stream = new Stream($this->_testConfig);
     $result = $stream->open();
     $data = "GET / HTTP/1.1\r\n";
     $data .= "Host: localhost\r\n";
     $data .= "Connection: Close\r\n\r\n";
     $this->assertTrue($stream->write($data));
     $result = $stream->eof();
     $this->assertFalse($result);
     $result = $stream->read();
     $this->assertPattern("/^HTTP/", $result);
 }