PHP RFC: Add suffix-parameter to tempnam
- Version: 1.0
- Date: 2013-02-25
- Author: Stefan Neufeind, neufeind@php.net
- Status: Under Discussion
- First Published at: http://wiki.php.net/rfc/tempnam-suffix
Introduction
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.
Proposal
Add new, optional parameter $suffix to tempnam().
Backward Incompatible Changes
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.
Proposed PHP Version(s)
5.6
SAPIs Impacted
all
Impact to Existing Extensions
none
Patches and Tests
Documentation-snippets
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"