By eHow Internet Editor
Rate: (2 Ratings)
Reading from and writing to files is one of the most common programming tasks. You can't process data if you don't get it from somewhere (most often a file), and you will usually need to store the result of the processing in something different from the volatile RAM. Again, one of the most common solutions is a file, in which you write the result of the processing. Of course, if you want to be able to read and write to files, you need to know how to open them.
$myFile = "simpleFile.txt";
$fh = fopen($myFile, 'r') or die("Can't open file");
fclose($fh);
$myFile = "simpleFile.txt";
$fh = fopen($myFile, 'r+') or die("Can't open file");
fclose($fh);
$myFile = "simpleFile.txt";<br>$fh = fopen($myFile, 'w') or die("Can't open file");<br>fclose($fh);
$myFile = "simpleFile.txt";<br>$fh = fopen($myFile, 'w+') or die("Can't open file");<br>fclose($fh);
$myFile = "simpleFile.txt";
$fh = fopen($myFile, 'a') or die("Can't open file");
fclose($fh);
$myFile = "simpleFile.txt";
$fh = fopen($myFile, 'a+') or die("Can't open file");
fclose($fh);
eHow Internet Editor