public function write($string, $length = null)
    {
        if (null === $length) {
            $length = strlen($string);
        }

        if (false === ($actual = @fwrite($this->getHandle(), $string, $length))) {
            throw FileException::createUsingLastError();
        }

        if ($length !== $actual) {
            throw FileException::createUsingFormat(
                'Only %d of %d bytes were written to "%s".',
                $actual,
                $length,
                $this->file
            );
        }
    }
public function write($string, $length = null)
    {
        if (null === $length) {
            $length = strlen($string);
        }

        if (false === ($actual = @fwrite($this->getHandle(), $string, $length))) {
            throw FileException::createUsingLastError();
        }

        if ($length !== $actual) {
            throw FileException::createUsingFormat(
                'Only %d of %d bytes were written to "%s".',
                $actual,
                $length,
                $this->file
            );
        }
    }
public function write ( $ string , $ length = null ) { if ( null === $ length ) { $ length = strlen ( $ string ) ; } if ( false === ( $ actual = @ fwrite ( $ this -> getHandle ( ) , $ string , $ length ) ) ) { throw FileException :: createUsingLastError ( ) ; } if ( $ length !== $ actual ) { throw FileException :: createUsingFormat ( 'Only %d of %d bytes were written to "%s".' , $ actual , $ length , $ this -> file ) ; } }
Writes a specific number of bytes to the file.

This method will attempt to write the exact string, or the length
specified. If the whole string, or the specified length, could not
be written, an exception will be thrown.

$writer->write($data);

@param string  $string The string to write to the file.
@param integer $length The number of bytes of the string to write.

@throws Exception
@throws FileException If the file could not be written.

@api
Writes a specific number of bytes to the file .