Create a file
Posted: Tue Sep 26, 2006 9:15 am
I eas wandering if any one knew what is the comad that i can create a new text file from a online interface
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
Code: Select all
#create handle
$fp = fopen('youfile.txt', 'w'); //'w' specifies that you want to create it if its not created.
//If the textfile for which you choose to write is created use 'a' which means append to the end of a file.
$write_string = "it works!"; //contents you chose to write.
if($fp) {
fwrite($fp, $write_string); //write_string can be any variable, I just chose it for this example.
} else {
die(); // instructs the file to stop if something goes wrong.
}