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?



How do I open a file to write content to?..

Answer / 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

More PHP Interview Questions

How to create a public static method in PHP?

0 Answers  


Explain PHP looping?

0 Answers  


What is call by reference in php?

0 Answers  


Tell me what is the main difference between php 4 and php 5?

0 Answers  


How can we connect to a mysql database from a php script?

0 Answers  


What is the substitution of submit in PHP?

6 Answers   RedAlkemi,


How to remove an empty directory?

0 Answers  


Is array function in php?

0 Answers  


If we login more than one browser windows at the same time with same user and after that we close one window, then is the session is exist to other windows or not? And if yes then why? If no then why?

0 Answers  


What is session cookies php?

0 Answers  


What are the __construct() and __destruct() methods in a php class?

0 Answers  


What is the difference between client-side and server-side programming?

0 Answers  


Categories