note 97086 added to function.tempnam
| From: | ArturGraniszewski at osu1 dot php dot net | Date: | Wed, 31 Mar 2010 18:57:22 +0000 |
| Subject: | note 97086 added to function.tempnam | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-167593@lists.php.net to get a copy of this message | ||
tempnam() function does not support custom stream wrappers registered by stream_register_wrapper().
For example if you'll try to use tempnam() on Windows platform, PHP will try to generate unique
filename in %TMP% folder (usually: C:\WINDOWS\Temp) without any warning or notice.
<?php
// << ...custom stream wrapper goes somewhere here...>>
echo '<pre>';
error_reporting(E_ALL);
ini_set('display_errors', true);
clearstatcache();
stream_register_wrapper('test', 'MemoryStream');
mkdir('test://aaa');
mkdir('test://aaa/cc');
mkdir('test://aaa/dd');
echo 'PHP '.PHP_VERSION;
echo '<br />node exists: '.file_exists('test://aaa/cc');
echo '<br />node is writable: '.is_writable('test://aaa/cc');
echo '<br />node is dir: '.is_dir('test://aaa/cc');
echo '<br />tempnam in dir: '.tempnam('test://aaa/cc', 'tmp');
echo "<br /></pre>";
?>
ouputs:
--------------------
PHP 5.2.13
node exists: 1
node is writable: 1
node is dir: 1
tempnam in dir: C:\Windows\Temp\tmp1D03.tmp
If you want to create temporary file, you have to create your own function (which will probably use
opendir() and fopen($filename, "x") functions)
----
Server IP: 194.24.174.37
Probable Submitter: 82.210.157.150
----
Manual Page -- http://www.php.net/manual/en/function.tempnam.php
Edit -- https://master.php.net/note/edit/97086
Del: integrated -- https://master.php.net/note/delete/97086/integrated
Del: useless -- https://master.php.net/note/delete/97086/useless
Del: bad code -- https://master.php.net/note/delete/97086/bad+code
Del: spam -- https://master.php.net/note/delete/97086/spam
Del: non-english -- https://master.php.net/note/delete/97086/non-english
Del: in docs -- https://master.php.net/note/delete/97086/in+docs
Del: other reasons-- https://master.php.net/note/delete/97086
Reject -- https://master.php.net/note/reject/97086
Search -- https://master.php.net/manage/user-notes.php