Each handle points to an independent stream. Example:
$a = fopen('php://memory', 'w+');
$b = fopen('php://memory', 'w+');
fwrite($a, 'foo');
fwrite($b, 'bar');
rewind($a);
rewind($b);
$a_text = stream_get_contents($a); //=> "foo"
$b_text = stream_get_contents($b); //=> "bar"
fclose($a);
fclose($b);
This is not explicitly documented anywhere, but it is implicit in the documentation for streams and wrappers.
From the official php documentation on streams in general, it is clear that for the standard case of streams, each file handle is associated with it's own independent stream.
And in the documentation on IO stream wrappers, it lists the possible wrappers noting exceptions as they occur. There is an exception listed for the first three (stdin, stdout, stderr):
php://stdin, php://stdout and php://stderr allow direct access to the
corresponding input or output stream of the PHP process. The stream
references a duplicate file descriptor, so if you open php://stdin and
later close it, you close only your copy of the descriptor-the actual
stream referenced by STDIN is unaffected.
But no such exception is listed for php://temp
or php://memory
. Hence it follows that these would work like normal independent streams.
Also, there are some comments on these pages that further imply the Independence of these streams.