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 |
how to use particular city location in php?
I have two radio button, i click one radio button display one dropdown box, one text field. and then click another radio button display one text field.so any one give me good idea plz.....i used <div id="" style=display:none> but not work..
Explain what is meant by pear in php?
What is the use of stripslashes in php?
What are the 5 types of data?
1.What is application server ? 2.What is web server ? 3.Explain the process of execution of a php file ?
Tell me what does the scope of variables means?
How can we submit a form without a submit button? What is the use of obj_star?
2 Answers Rushmore Consultancy,
Why is overriding runtime?
What is the method to register a variable into a session?
Do I need to install php after xampp?
How do I run a php file?