Signatur
tempnam(string $directory, string $prefix): string|false
Beschreibung
Sicherer als uniqid()-basierte Pfade — Race-Condition-frei.
Parameter
| Name | Typ | Default | Beschreibung |
|---|---|---|---|
| $directory Pflicht | string | — | Ziel-Verzeichnis. |
| $prefix Pflicht | string | — | Präfix. |
Rückgabewert
Typ
string|false
Beschreibung
Pfad.
Beispiele
Atomarer Schreib-Zyklus
<?php
$tmp = tempnam(sys_get_temp_dir(), 'export');
file_put_contents($tmp, $payload);
rename($tmp, $targetPath); // atomar