This question is closely related to my new findings, regarding this question.
Is there any way to preserve the in stream data of php://memory or php://temp between handles? I read (somewhere I can’t source off hand) that subsequent openings of the aforementioned streams clears existing data.
$mem1 = fopen('php://memory', 'r+');
fwrite($mem1, 'hello world');
rewind($mem1);
fpassthru($mem1); // "hello world"
$mem2 = fopen('php://memory', 'r+');
rewind($mem2);
fpassthru($mem2); // empty
So again my question is, is there anyway to force existing data to persist in stream when creating a new handle to it?
(The latter call to fpassthru() would of course dump hello world given this is possible)
Opening one of the pseudo-streams
php://temporphp://memoryalways opens a new stream, what means, that every stream your open this way is unique. So you can’t read the content of the stream you have previously written to another one.