ConFoo Montreal 2026: Call for Papers

Voting

: nine plus zero?
(Example: nine)

The Note You're Voting On

tomas at slax dot org
15 years ago
Beware: functions are not atomic. If many processes call the same function at the same time, you may end up with unwanted behavior.

If you need your own variant of tempnam, use something like this:

<?php
function tempnam_sfx($path, $suffix)
{
do
{
$file = $path."/".mt_rand().$suffix;
$fp = @fopen($file, 'x');
}
while(!
$fp);

fclose($fp);
return
$file;
}

// call it like this:
$file = tempnam_sfx("/tmp", ".jpg");
?>

You may replace mt_rand() by some other random name generator, if needed.

<< Back to user notes page

To Top