lithium\net\socket\Stream::write PHP Method

write() public method

writes data to the stream resource
public write ( string $data = null ) : mixed
$data string The string to be written.
return mixed False on error, number of bytes written otherwise.
    public function write($data = null)
    {
        if (!is_resource($this->_resource)) {
            return false;
        }
        if (!is_object($data)) {
            $data = $this->_instance($this->_classes['request'], (array) $data + $this->_config);
        }
        return fwrite($this->_resource, (string) $data, strlen((string) $data));
    }

Usage Example

Example #1
0
 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());
 }
All Usage Examples Of lithium\net\socket\Stream::write