rfc:tempnam-suffix

PHP RFC: Add suffix-parameter to tempnam

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"
rfc/tempnam-suffix.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1