note 82469 added to function.fseek
| From: | Anonymous at osu1 dot php dot net | Date: | Sat, 12 Apr 2008 05:45:54 +0000 |
| Subject: | note 82469 added to function.fseek | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-138206@lists.php.net to get a copy of this message | ||
To:seeker at example com
Be careful, though.
You can freely position you pointer if you open a file in (r+) mode, but it will
"overwrite" the data, not "append it".
Tested this:
<?php
// file.txt content:
// "You can contribute your notes to the PHP manual from the comfort of your browser!"
$handler = fopen("file.txt", "r+");
fseek($handler, 0);
fwrite($handler, "want to add this");
?>
New contents of the file.txt will be like this:
"want to add thiste your notes to the PHP manual from the comfort of your browser!".
If you really want to append at the beginning, you have to first get all the contents, save it,
clear the file, put the new contents and append the saved contents at the end.
----
Server IP: 61.195.146.164
Probable Submitter: 218.43.38.239
----
Manual Page -- http://www.php.net/manual/en/function.fseek.php
Edit -- https://master.php.net/note/edit/82469
Del: integrated -- https://master.php.net/note/delete/82469/integrated
Del: useless -- https://master.php.net/note/delete/82469/useless
Del: bad code -- https://master.php.net/note/delete/82469/bad+code
Del: spam -- https://master.php.net/note/delete/82469/spam
Del: non-english -- https://master.php.net/note/delete/82469/non-english
Del: in docs -- https://master.php.net/note/delete/82469/in+docs
Del: other reasons-- https://master.php.net/note/delete/82469
Reject -- https://master.php.net/note/reject/82469
Search -- https://master.php.net/manage/user-notes.php