Access a temporary file created by SplTempFileObject by another file handle instance
| From: | Christian Kaps | Date: | Sun, 01 May 2011 19:23:44 +0000 |
| Subject: | Access a temporary file created by SplTempFileObject by another file handle instance | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-52128@lists.php.net to get a copy of this message | ||
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