Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

How do I open a file to write content to?

Answer Posted / jude jeevanraj.p

Working with files and folders in PHP is fairly easy though
it can take a little while to get used 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.

<?php

$myfile = fopen("example.txt","w");
fwrite($myfile,"That was easy!");
fclose($myfile);
?>

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is mysql in php?

982


How to list all values of submitted fields?

987


What is the function file_get_contents() useful for?

986


how can i develop forum code? any one pleale help me on this question

1987


What are the benefits of using queries?

1235


How to update memcached when you make changes to php?

1024


What is the function of string in c?

1050


How to get a total number of elements used in the array?

1036


Which is best framework for php?

1071


Is nan in php?

1097


Can php run without apache?

1066


What is the use of session and cookies in php?

1049


What are the differences between PHP3 and PHP4 and PHP5? what is the current stable version of PHP?

1178


What does php exit do?

1120


What is the use of mysql_fetch_array in php?

1087