Page 1 of 1

[SOLVED] $output to text file

Posted: Tue Aug 03, 2004 11:41 am
by FormatteD_C
I am a newb at php so please bare with me : )

I have an $output and I would like the output to be written to a text file, I dunno if it should go something like this

Code: Select all

$filename = "/usr/local/something.txt"; 
$handle = fopen($filename, "r");
and then I dunno... : )

fwrite...


thank you

Posted: Tue Aug 03, 2004 12:37 pm
by nigma

Code: Select all

fwrite($handle, $content);
fwrite returns false on error.

http://us2.php.net/manual/en/function.fwrite.php

Posted: Tue Aug 03, 2004 12:38 pm
by kettle_drum

Code: Select all

$filename = "/path/tp/file";
$fp = fopen($filename, "a"); //appends to the file r = read, w = write from start of file
fwrite($fp, "put this in the file");
fclose($fp);

thanks

Posted: Tue Aug 03, 2004 11:07 pm
by FormatteD_C
Thanks works great