Oihana PHP

makeTemporaryDirectory.php

Table of Contents

Functions

makeTemporaryDirectory()  : string
Creates (or returns if already present) a directory inside the system temporary folder.

Functions

makeTemporaryDirectory()

Creates (or returns if already present) a directory inside the system temporary folder.

makeTemporaryDirectory(string|array<string|int, string>|null $path[, int $permission = 0755 ]) : string

The sub‑path is appended to sys_get_temp_dir() de la même manière que getTemporaryDirectory() :

  • null → the temp dir itself
  • 'cache'/tmp/cache
  • ['my', 'app']/tmp/my/app
Parameters
$path : string|array<string|int, string>|null

Optional sub‑directory path segments.

$permission : int = 0755

Octal mode for mkdir() (default: 0755).

Tags
throws
DirectoryException

If creation fails or the directory is still missing afterwards.

example
// 1) Ensure /tmp/reports exists
$reportsDir = makeTemporaryDirectory('reports');

// 2) Ensure /tmp/my/app/cache exists
$cacheDir = makeTemporaryDirectory(['my','app','cache'], 0700);

// 3) Just return /tmp itself
$tmp = makeTemporaryDirectory(null);
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

Full path to the (existing or newly created) temporary directory.


        
On this page

Search results