<html> <head> <title>Writing and appending to a file</title> </head> <body> <?php $filename = "test1.txt"; print "Writing to $filename<br>"; $fp = fopen( $filename, "w" ) or die("Couldn't open $filename"); fwrite( $fp, "Hello worldn" ); fclose( $fp );
print "Appending to $filename<br>"; $fp = fopen( $filename, "a" ) or die("Couldn't open $filename"); fputs( $fp, "And another thingn" ); fclose( $fp ); ?> </body> </html>
|