How do I open a file to write content to?
You need to create a filehandle, which is a pointer to a file, that you wish to write too.
Use the fopen function to open a file, and pass the name of the file as the first parameter and what you want to do with it second - in this case 'w' for write.
Then simple use fwrite to write to your file, and close it with fclose.
Here's a simple example that will create a file in the directory called example.txt and write to it with just a few lines of PHP code.
$myfile = fopen("example.txt","w");
fwrite($myfile,"That was easy!");
Congratulations, you have just written text to a file using PHP!
If you get an error message doing this on a web server, make sure you have the relevant permissions to write to the directory you are running the script in.
More files PHP QuestionsHow do i keep my site menu in one file?
i have a VPS(OS:windowsServer2003) with 1Gbps InternetSpeed ,and i install FilezillaClient and WampServer on this vps,and i have a netload.in account,i uploaded file(size:4GB)by filezilla client to netload ftpserver and speed of uploading was goood,but wh
Hello, I have a php file that has octet binary numbers in it. How can I see the actual wording? This is an example of how it look: 00111010 11010010 And so on.
how to upload large files like mp3 songs in php
I am trying to find the most recent directory that I am working in. example http://www.mysite.com/apples/index.php how do I get php to find the directory "apples" so I can make it a directory