- ⌂ stream_writer
- Methods
stream_writer::open_temp()
Convenience method to open a temporary file stream in a given directory. The given directory must exist and be writeable. The caller of this function is responsible for unlinking the temporary file.
Prototype
boolean open_temp(string $directory = NULL, string $prefix = NULL)
Parameters
- directory - Name of the file to open for writing.
- prefix - Optional prefix to apply to the unique filename in the directory. If not specified uses a default file prefix.
Return
Always returns TRUE. Throws a COMAND Exception upon failure.
Example
namespace \io_comand_file\stream_writer;
try {
$out = new stream_writer();
$out->open_temp('/tmp');
$out->write('Some text.');
$out->close();
} catch(\io_comand\exception $e) {
echo('Temp File Write Error: ' . $e->getMessage());
}