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 |
Differentiate echo vs. Print statement.
Which escape sequences can be used in single quoted strings in php?
What is super keyword in php?
Which function is used in php to delete a file?
Is array empty php?
Explain what are some new features introduced in php7?
Explain what is the difference between session and cookie?
Which programming language does php resemble to?
What is the use of token in php?
hi sir am a fresher just learning LAMP COURSE linux,apache,mysql and php .just i finished my M.C.A 2009 passed out ..can any one tell after i finish this course how much salary we expect in any php based company ? and also tell please how much salary we can demand as a fresher with my M.C.A qualification as a PHP fresher in a company ? how much we get atleast mininum as a PHP fresher in CHENNAI and Bangalore just send ur valuable suggestions to kiranpulsar2007@gmail.com please guide to me sir
How to download and install php on windows?
What is the use of "ksort" in php?