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 |
Can anybody plz tell me if there any recruitment on php plz mail to vasudev.adepu@gmail.com.i had completed M.SC(MATHS) in 2007 . trying to get a job on php. i have good knowledge on PHP/MYSQL
Which is the correct way to check if a session has already been started ?
What is a php trait?
What is polymorphism in oop php?
Can I run php without xampp?
how to get the value in script values
How to get the position of the character in a string in php?
I have 10 elements of Array, how can i remove 5 array element, with single function.
How to set cookies?
How to find a substring from a given string in php?
Why do we use javascript in php?
Which method do you follow to get a record from a million records? (Searching not from database, from an array in php)?