I have written a function to write data in a doc file,
public function createDoc($dir) {
if ($_REQUEST) {
header("Content-type: application/vnd.ms-word");
header("Content-Disposition: attachment;Filename = MyDoc.doc");
$all_txt_files = glob($dir.'/*.txt');
foreach ($all_txt_files as $file) {
$fileParts = explode('/', $file);
$this->outputContent .= "<h1>".$fileParts[count($fileParts) - 1]."</h1><p>".file_get_contents($file)."</p>";
echo "<h1>".$fileParts[count($fileParts) - 1]."</h1><p>".file_get_contents($file)."</p>";
}
}
return $this->outputContent;
}
but, after returning from this function still, each echo statement write in the same file, how to prevent that?
j
stuff ;)
the echo is directed to stdout so the echo is not written to the file. also I hope you made a doc_root locking in your fpm/webserver.
unless you use ob_start and flush, but it does not look that ways :)