Current it is possible to optionally specify a prefix to generated filenames. In some cases however it is needed to create files with a certain suffix (like a file-extension) because other tools rely on for example a graphic-name ending with .png.
There is already a “prefix”-parameter that will be used in front of the automatically generated temporary name. The “suffix” proposed here, if specified, will be added to the end of the resulting temporary name.
Add new, optional parameter $suffix to tempnam().
The suffix-parameter is optional. Thus it is transparent to any existing PHP-code in use.
Only internal API if affected because of the additional parameter which is added.
5.6
all
none
string tempnam ( string $dir , string $prefix [, string $suffix] )
suffix The suffix of the generated temporary filename.
Changelog: 5.6.0 The suffix parameter was added
Example #2 tempnam() example
$tmpfname = tempnam("/tmp", "FOO", ".png"); echo $tmpfname; // will be "/tmp/FOO<something>.png"