|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15553 fopen() when using r+ overwrites whateva is at top
Submitted: 2002-02-14 09:35 UTC Modified: 2002-02-14 14:15 UTC
From: smythe at smythey dot org Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 4.1.1 OS: Win2K
Private report: No CVE-ID: None
 [2002-02-14 09:35 UTC] smythe at smythey dot org
$output = "\nGday.\n";
$directory = dirname($path_translated);
$filename = fopen($directory . "members/addop.txt", "r+", 1) or die("Can't open file");
if ($output) { 
$written = fwrite($filename, $output) or die ("Couldn't write to file");

When usin r+ it writes to the file addop.txt but just overwrites whateva is at the top. i want it to just add to the top of the file. 


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2002-02-14 14:15 UTC]
That's 'cause that what 'r+' does:

The underlying system call does not support prepending to
files--this is a pretty common request, in fact. For
solutions, please ask on the
support list or check out
for help.

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue Jun 22 13:01:23 2021 UTC