# Access a temporary file created by SplTempFileObject by another file handle instance

- Thread: https://externals.io/message/52128
- Original archive: https://news-web.php.net/php.internals/52128
- Started by Christian Kaps on 2011-05-01T19:23:44+00:00
- Messages: 1
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #52128 — Christian Kaps — 2011-05-01T19:23:44+00:00

URL: https://externals.io/message/52128#52128

Hi,

is there any reason why a temporary file created with SplTempFileObject
isn't accessible by another e.g. SplFileObject instance.

$temp = new SplTempFileObject();
$temp->fwrite('A string');
var_dump($temp->getPathname());

The var_dump call returns always the PHP stream URL php://temp. Why the
method getPathname doesn't return a unique ID in the
URL(php://temp/ertZ789) which references to this temporary file. So it
would be posible to access this temporary file by another e.g.
SplFileObject instance.

For testing purpose this would be a great benefit. With a
SplTempFileObject instance a test fixture could be created in RAM. It
would like a virtual file system for one file.

Greetings
Christian
