Create a 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
moiseszaragoza
Forum Commoner
Posts: 87
Joined: Sun Oct 03, 2004 4:04 pm
Location: Ft lauderdale
Contact:

Create a file

Post 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
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post 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.                  
}
User avatar
moiseszaragoza
Forum Commoner
Posts: 87
Joined: Sun Oct 03, 2004 4:04 pm
Location: Ft lauderdale
Contact:

Post by moiseszaragoza »

Thanks

you dont know how much you helped me out
User avatar
akimm
Forum Contributor
Posts: 460
Joined: Thu Apr 27, 2006 10:50 am
Location: Ypsilanti Michigan, formally Clipsburgh

Post 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.
User avatar
moiseszaragoza
Forum Commoner
Posts: 87
Joined: Sun Oct 03, 2004 4:04 pm
Location: Ft lauderdale
Contact:

Post by moiseszaragoza »

i know

i love this place
User avatar
Maugrim_The_Reaper
DevNet Master
Posts: 2704
Joined: Tue Nov 02, 2004 5:43 am
Location: Ireland

Post 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.
User avatar
a94060
Forum Regular
Posts: 543
Joined: Fri Feb 10, 2006 4:53 pm

Post by a94060 »

your welcome
Post Reply