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.