PHP write files, PHP and ASP can be the same as the operation of the file,fwrite to write the file
Now that you know how to open and close a file, you can get the most useful part of the file operation, write! There is really only one main function that is used for writing and its logic requires fwrite.
PHP-Open File: Inbox
Before we can write information to our test file, we must use the feature open to open the file in written form.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' w ');
PHP Write File: fwrite function www.111cn.net/phper/php.html
We can write to a text file using PHP. The Fwrite feature enables you to write data to any type of file. The first parameter of the fwrite is the file processing and its second parameter is a series of data written. Just give these two functions bits of information and you are good to go!
Below, we are writing a couple of names to our test files TestFile.txt and they separated the carriaged back.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' w ') or Die ("can ' t open file");
$stringData = "Bobby Boppern";
Fwrite ($FH, $stringData);
$stringData = "Tracy Tannern";
Fwrite ($FH, $stringData);
Fclose ($FH);
Dollar frequency hopping variable contains the file handle TestFile.txt. The file handles knowledge of the current file pointer, which is written in the form of the beginning of the file.
We wrote to the file TestFile.txt two times. Every time we write to us send a file to the string $ stringdata, the first to load Bobby Bopper and the second to load Tresitana. When we finish writing, we close the file and use the Fclose feature.
If you open TestFile.txt in Notepad the file will look like this:
content TestFile.txt file:
Bobby bopper
Tresitana
php-file inbox: Overwrite
this te StFile.txt now contains some data that we can prove when you open an existing file for a written reply. All data contained in the file is wiped clean and you start with an empty file. In this example, we open our existing file TestFile.txt write some new data to it.
$myFile = "TestFile.txt";
$fh = fopen ($myFile, ' w ') or Die ("can ' t open file");
$stringData = "Floppy Jal Opyn ";
Fwrite ($fh, $stringData);
$stringData = "Pointy Pinton";
Fwrite ($fh, $stringData);
Fclose ($FH);