|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76900 overwriting start of stream truncates the end
Submitted: 2018-09-18 14:06 UTC Modified: 2018-09-18 14:13 UTC
From: sjon at hortensius dot net Assigned:
Status: Not a bug Package: Streams related
PHP Version: 7.3.0RC1 OS: archLinux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
Solve the problem:
27 - 21 = ?
Subscribe to this entry?

 [2018-09-18 14:06 UTC] sjon at hortensius dot net
after fseeking a stream and fwriting less data to it, the previous available data is gone


Test script:

$socket = fopen('php://memory', 'a+');
fwrite($socket, 'ab');
fseek($socket, 0);

fwrite($socket, 'a');


Expected result:
string(1) "b"

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2018-09-18 14:13 UTC]
-Status: Open +Status: Not a bug
 [2018-09-18 14:13 UTC]
See bug #75031.
> 'a+'
> ...In this mode, fseek() only affects the reading position, writes are always appended.
 [2018-09-18 23:51 UTC] a at b dot c dot de
As for "the previous available data is gone" bit...


$socket = fopen('php://memory', 'a+');
fwrite($socket, 'ab');
fseek($socket, 0);

fwrite($socket, 'a');

fseek($socket, 0);

PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Tue May 18 03:01:24 2021 UTC