webCOMAND

stream_writer::__construct()

Create an output stream to write to.

Prototype

stream_writer __construct(string $mode = NULL, array $options = [])

Parameters

  • mode - One of the following modes.
    • output_stream::FILE - A standard file.
    • output_stream::TEMP - A temporary file.
    • output_stream::STREAM - An abstract stream.
    • output_stream::BROWSER - A web browser response.
    • output_stream::STDOUT - Standard output, such as the screen.
    • output_stream::STRING - A string in memory.
  • options - An associative array with zero or more key/value pairs.  See the corresponding output stream type for recognized key/value pairs.

Example

namespace \io_comand_file\stream_writer;
namespace \io_comand_file\output_stream;

$out = new stream_writer(output_stream::FILE, [
    'filename' => 'test.txt'
]);
$out->write('Some text.');
$out->close();