<?php
detour@metalshell.com
http://www.metalshell.com/
$outfile = "tmpfile";
$writestring = "first line\nsecond line\nthird line\n";
$appendstring = "fourth line\n";
if(!$fd = fopen($outfile, "w")) {
echo("Error opening file.");
exit;
}
if(!fwrite($fd, $writestring)) {
echo("Error writing file.");
exit;
}
fclose($fd);
echo("The file now contains:<br>");
print_file($outfile);
if(!$fd = fopen($outfile, "a")) {
echo("Error opening file.");
exit;
}
if(!fwrite($fd, $appendstring)) {
echo("Error writing file.");
exit;
}
fclose($fd);
echo("The file now contains:<br>");
print_file($outfile);
function print_file($file) {
if(!$inf = fopen($file, "r"))
return;
$data = fread($inf, filesize($file));
$data = ereg_replace("\n", "<br>", $data);
echo $data;
}
?>