[SOLVED] $output to text file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
FormatteD_C
Forum Newbie
Posts: 10
Joined: Tue Oct 21, 2003 5:08 pm
Location: Ohio
Contact:

[SOLVED] $output to text file

Post 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
User avatar
nigma
DevNet Resident
Posts: 1094
Joined: Sat Jan 25, 2003 1:49 am

Post by nigma »

Code: Select all

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

http://us2.php.net/manual/en/function.fwrite.php
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post 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);
User avatar
FormatteD_C
Forum Newbie
Posts: 10
Joined: Tue Oct 21, 2003 5:08 pm
Location: Ohio
Contact:

thanks

Post by FormatteD_C »

Thanks works great
Post Reply