View Full Version : Copying the contents of one file to another

Dr. Lecter
09-10-2005, 09:53 PM
Does anyone know how to make the contents of a file a variable so they can be added to the end of another file... I tried to use !copy, not realizing that it literally copied the file onto the other. I've tried the php.net manual, but I can't find anything that works. Its probably something really simple but its been bugging me for the last hour, since I got everything else working but this.

09-10-2005, 10:11 PM
fopen() with mode a or a+
PHP5: file_put_contents() with FILE_APPEND flag

09-10-2005, 10:38 PM
Also file_get_contents()


09-10-2005, 11:51 PM
Huh? file_GET_contents()?

09-11-2005, 12:32 AM
Ahh sorry, I should have made it more clear... I was talking about an easy way to get the entire file as a string (to then be written using fopen()/fwrite()).

Dr. Lecter
09-11-2005, 01:45 AM
Can someone explain the usage of file_get_contents since I can't seem to get anything but false whenever I use it.

09-11-2005, 01:56 AM

Dr. Lecter
09-11-2005, 03:25 AM
Wow! Thanks, it works :thumbsup: