Page 1 of 1

Create a file

Posted: Tue Sep 26, 2006 9:15 am
by moiseszaragoza
I eas wandering if any one knew what is the comad that i can create a new text file from a online interface

Posted: Tue Sep 26, 2006 9:26 am
by a94060

Posted: Tue Sep 26, 2006 10:07 am
by akimm
and if you can't figure that out.


remember this

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.                  
}

Posted: Tue Sep 26, 2006 10:37 am
by moiseszaragoza
Thanks

you dont know how much you helped me out

Posted: Tue Sep 26, 2006 10:44 am
by akimm
Well I do, because a month ago I asked similar questions, and got the same sort of answers. Its no problem, this community helps me way too much for me not to help if and when I can hehe.

Posted: Tue Sep 26, 2006 10:52 am
by moiseszaragoza
i know

i love this place

Posted: Tue Sep 26, 2006 11:32 am
by Maugrim_The_Reaper
Make sure you use the right fopen() flags (like 'w') for the right scenario...
Windows systems require an additional flag at times, usually "t". See the description under the flag listing in the manual.

Posted: Tue Sep 26, 2006 2:20 pm
by a94060
your welcome