php.net |  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");
}
fclose($filename);
?>

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. 

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

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

  http://www.php.net/fopen

The underlying system call does not support prepending to
files--this is a pretty common request, in fact. For
solutions, please ask on the php-general@lists.php.net
support list or check out http://www.php.net/support.php
for help.


Torben
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 01:01:30 2024 UTC