note 10423 deleted from function.fopen by hholzgra
| From: | hholzgra@php.net | Date: | Fri, 12 Jul 2002 15:04:57 +0000 |
| Subject: | note 10423 deleted from function.fopen by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-32988@lists.php.net to get a copy of this message | ||
For people new to PHP, like I was several a month ago this will help out with the
"functionallity" of fopen(). You can use multiple modes, or how to go about procedures
with the file at hand.
Inside the second parameter, the mode, can contain two letters. So if you were to put an
"a" and a "w" there,
ex. $fp = fopen ("text.txt", "aw");
it would behave as follows: When you fputs() something to the text.txt it will do everything that
"a" does, but it will also carry over some attributes of "w"; In this case it
will place the file pointer to the begining of the file, which I find quite handy.
Here is an example of a little script taking advantage of this:
<?
$fp = fopen ("php.txt", "aw");
$fputs ("$name, $date, $title, $news);
fclose ($fp);
?>
This simply will take variables and write them into the *top* of a text file without deleting any of
the origional text.
-Peter
PS> PHP ROCKS!